Memcached prepend Command
The Memcached prepend command is used to prepend data before an existingkeyofvalue.
Syntax:
The basic syntax format of the prepend command is as follows:
prepend key flags exptime bytes [noreply] value
The parameter descriptions are as follows:
- key:key in the key-value structure, used to find the cached value.
- flags: An integer parameter that can include key-value pairs. The client uses it to store additional information about key-value pairs.
- exptime: The length of time to save 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 not to return data
- value: The stored value (always on the second line) (can be directly understood as the value in the key-value structure)
Example
The example is as follows:
- First, we store a key example in Memcached, with its value being memcached.
- Then, we use the get command to retrieve the value.
- Then, we use theprependcommand to prepend "redis" to the front of the value of the key example.
- Finally, we use the get command again to retrieve the value.
set example 0 900 9 memcached STORED get example VALUE example 0 9 memcached END prepend example 0 900 5 redis STORED get example VALUE example 0 14 redismemcached END
Output
If the data is added successfully, the output is:
STORED
Output information description:
- STORED: Output after successful save.
- NOT_STORED: The key does not exist in Memcached.
- CLIENT_ERROR: Execution error.