Memcached basic syntax record

Time:2019-11-29

Set command: the command stores the value value value in the specified key;

set key flags exptime bytes [noreply] 
value 
  • key:The key in the key value structure, used to find the cache value.
  • flags: can include integer parameters for key value pairs that clients use to store additional information about key value pairs.
  • exptime: the length of time (in seconds, 0 means forever) to save the key value pair in the cache
  • bytes: number of bytes stored in cache
  • Noreply (optional): this parameter tells the server that it does not need to return data
  • value: stored value (always on the second line) (directly understood as value in the key value structure)
set yx 0 900 9
memcached
Stored indicates successful setting; get YX
Stored: output after saving successfully.
Error: output after saving failure.

Add command:

The memcached add command is used toValue (data value)Store in the specifiedKey (key)Medium. If the key of add already exists, the data will not be updated (the expired key will be updated), the previous value will remain the same, and you will get the responseNOT_STORED

add key flags exptime bytes [noreply]
value
  • key:The key in the key value structure, used to find the cache value.
  • flags: can include integer parameters for key value pairs that clients use to store additional information about key value pairs.
  • exptime: the length of time (in seconds, 0 means forever) to save the key value pair in the cache
  • bytes: number of bytes stored in cache
  • Noreply (optional): this parameter tells the server that it does not need to return data
  • value: stored value (always on the second line) (directly understood as value in the key value structure)
Stored: output after saving successfully.
Not saved: output after saving failure.

For details, please see: https://www.runoob.com/memcached/memcached-replace-data.html