hackjutsu / hackjutsu/memcached-java-demo
memcached 命令行
- Vorherrschende Sprache
- Java
- Sterne
- 1
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Starting memcached
### 默认端口 11211, 如果想要改变端口,用-p
```
memcached -p 8000
memcached -d -p 8000
```
### 如何判断memcached已经启动过了
```
ps aux | grep memcached
```
### 退出memcached
```
quit
```
### 终止memcached service
```
brew install pidof
pidof memcached
```
```
kill -9
```
```
memcached -p 11111 -U 11111 -u user -d
-p is for TCP port number
-U is for UDP port number
-u is for user name
-d runs memcached as daemon process
```
## Connect to memcached
```
# 连接 memcached
telnet 127.0.0.1 11211
```
## Storage Commands
### Set Data
Memcached set command is used to set a value to key; if the key does not exist, a new key is created and value is assigned to that key.
`set key flags exptime bytes`
- key - It is the name of the unique key by which data is accessed.
- flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
- exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire". If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
- bytes - This is the length of the data in bytes that needs to be stored in Memcached.
- value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.
```
// bytes 要和value的character数目完全一样
set bittiger 0 900 9
memcached
get bittiger
```
### Add Data
Memcached `add` command is used to set a value to a new key. If the key already exists, then it gives the output NOT_STORED.
```
add key flags exptime bytes
value
```
### Replace Data
Memcached `replace` command is used to replace the value of an existing key.
```
replace key flags exptime bytes
```
### Append/Prepend
Memcached `append/prepend` command is used to add data in an existing key. This data is added at the `start/end` of the previous value.
```
append key flags exptime bytes
```
### CAS (Check-And-Set)
Memcached CAS command 'checks' and 'set' data item if and only if, no other client process has updated it since last read by this client. The `unique_cas_token` is obtained from the `gets` command.
[Reference](https://www.tutorialspoint.com/memcached/memcached_cas.htm)
```
cas key flags exptime bytes unique_cas_token
```
## Retrieval Commands
### Get
```
get key1 key2 key3
```
### Gets
Memcached gets command is used to get the value with CAS token.
```
gets key1 key2 key3
```
### Delete
```
delete key
```
### Incr/Decr
略
## Statistics Commands
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.