Memcached add command
The Memcached add command is used to store value(data value) in the specified key(key).
If add's key already exists, the data will not be updated, the previous value will remain the same, and you will get the response NOT_STORED.
Syntax:
The basic syntax format of the add command is as follows:
add key flags exptime bytes [noreply] value
The parameter description is as follows:
##key: The key in the key-value structure is used to find cached values.
flags: Integer parameter that can include key-value pairs and is used by the client to store additional information about the key-value pairs .
exptime: The length of time to keep key-value pairs in the cache (in seconds, 0 means forever)
bytes: The number of bytes stored in the cache
noreply (optional) : This parameter tells the server that no data needs to be returned
value: The stored value (always located in the second line) (can be directly understood as the value in the key-value structure)
- key → new_key
- flag → 0
- exptime → 900 (in seconds)
- bytes → 10 (number of bytes of data storage)
- value → data_value
add new_key 0 900 10 data_value STORED get new_key VALUE new_key 0 10 data_value ENDOutputIf the data is added successfully, output:
STOREDOutput information description:
STORED: Output after successful saving.
NOT_STORED : Output after a save failure.