Connect to the memcached command line: Telnet 127.0.0.1 11211
1.set/add/replace:
Format:<command> <key> <flags> <exptime> <bytes> (click Enter)
<data>
A) <command> can be "set", "Add", "replace".
"Set" means that the data is stored in accordance with the corresponding <key>, there is no time to increase, some overwrite.
"Add" means that the data is added according to the appropriate <key>, but the operation fails if the <key> already exists.
"Replace" means that the data is replaced by the appropriate <key>, but the operation fails if the <key> does not exist
b) <key> the client needs to save the data key.
c) <flags> is a 16-bit unsigned integer (expressed in decimal notation).
The flag is stored along with the data that needs to be stored and is returned when the client get data.
Customers can use this flag for special purposes and this flag is opaque to the server.
D) The time of <exptime> expires.
A 0 indicates that the stored data is never obsolete (but can be replaced by the server algorithm: LRU, etc.).
If it is not 0 (Unix time or the number of seconds in the distance), when it expires, the server can guarantee that the user will not get the data (server time is the standard).
e) <bytes> the number of bytes that need to be stored,,<bytes> can be 0 when the user wants to store empty data
f) <data block> stored data, the length is the same as the specified bytes, greater than and less than will be an error.
Set 0 0 3 leestored Set 0 0 3 leeeclient_error Bad Data chunkerror
2.get: you can get the value of multiple keys
Get03Lee
3. Deletion: Delete key time
// Delete name now Ten // Delete after 10s, test failed
4. Check the server Status:
Stats
PID: Process iduptime: Total run time, seconds time: Current times version: Revision number ... Curr_items: number of keyvalue in the current cache total_items: KeyValue number bytes: The amount of memory used by all caches curr_connections the current number of connections .... cmd_get: Total fetches Cmd_set: Total number of writes Get_hits: Total hits Miss_hits: Get the number of failures ... Bytes_read : Total bytes of traffic read Bytes_written: Total bytes of write traffic
Limit_maxbytes: Maximum allowable amount of memory, bytes
Stats Reset
Clear statistics
Stats malloc//test Failed
Display memory allocation data
Stats Cachedump slab_id Limit_num
Displays a list of the first limit_num keys in a slab
Stats Slabs
Displays information about each slab, including the size, number, usage, etc. of the chunk
Stats items
Displays the number of item in each slab and the age of the oldest item (the number of seconds the last access distance is now)
Stats detail [On|off|dump]
Set or display detailed operation Records
parameter is on to open detailed operation record
parameter is off, close verbose operation record
The parameter is dump, showing the detailed operation record (number of times each key value get, set, hit, Del)
Flush_all
Clear all Key values
Note: Flush does not delete items, except that all items are marked as expired, so Memcache still occupies all of the memory.
Command Description Example:
Get |
Reads a value |
Get MyKey |
Set |
Set a key unconditionally |
Set MyKey 0 60 5 |
Add |
ADD a new key |
Add Newkey 0 60 5 |
Replace |
Overwrite existing Key |
Replace key 0 60 5 |
Append |
Append data to existing key |
Append key 0 60 15 |
Prepend |
Prepend data to existing key |
Prepend Key 0 60 15 |
incr |
Increments numerical key value by given number |
INCR MyKey 2 |
Decr |
Decrements numerical key value by given number |
DECR MyKey 5 |
Delete |
Deletes an existing key |
Delete MyKey |
Flush_all |
Invalidate specific items immediately |
Flush_all |
Invalidate all items in n seconds |
Flush_all 900 |
Stats |
Prints General Statistics |
Stats |
Prints Memory Statistics |
Stats Slabs |
Prints Memory Statistics |
Stats malloc |
Print Higher level allocation statistics |
Stats items |
|
Stats Detail |
|
Stats sizes |
Resets statistics |
Stats Reset |
Version |
Prints Server version. |
Version |
Verbosity |
Increases log level |
Verbosity |
Quit |
Terminate Telnet session |
Quit |
memcached command-line operation detailed