Memcached prepend Command
The Memcached prepend command is used to prepend data before an already existing key 's value (data value) key .
Syntax:
The basic syntax format of the prepend command is as follows:
prepend key flags exptime bytes [noreply]
value
The parameters are described as follows:
- **key:** the key in the key-value structure, used to look up the cached value.
- flags: can include an integer parameter of the key-value pair, which the client uses to store extra information about the key-value pair .
- exptime: the length of time to keep the key-value pair 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 it does not need to return data
- value: the stored value (always on the second line) (can be understood directly as the value in the key-value structure)
Example
The example is as follows:
- First we store a key runoob in Memcached, with the value memcached.
- Then, we use the get command to retrieve the value.
- Then, we use the prepend the command prepends "redis" before the value of the key runoob.
- Finally, we use the get command again to retrieve the value.
set runoob 0 900 9
memcached
STORED
get runoob
VALUE runoob 0 9
memcached
END
prepend runoob 0 900 5
redis
STORED
get runoob
VALUE runoob 0 14
redismemcached
END
Output
If the data is added successfully, it outputs:
STORED
Description of the output information:
- STORED: output after a successful save.
- NOT_STORED: the key does not exist on Memcached.
- CLIENT_ERROR: execution error.