Memcached Append Command
The Memcached append command is used to append data to the existing value of a key.
Syntax:
The basic syntax format for the append command is as follows:
append key flags exptime bytes [noreply]
value
Parameter descriptions are as follows:
- key: The key in the key-value structure used to find the cached value.
- flags: An integer parameter that the client can use to store additional information about the key-value pair.
- exptime: The duration for which the key-value pair is stored in the cache (in seconds, 0 means forever).
- bytes: The number of bytes stored in the cache.
- noreply (optional): This parameter informs the server that no data needs to be returned.
- value: The stored value (always on the second line) (can be directly understood as the value in the key-value structure).
Example
Here is an example:
- First, we store a key "tutorialpro" with the value "memcached" in Memcached.
- Then, we retrieve the value using the get command.
- Next, we use the append command to append "redis" to the value of the key "tutorialpro".
- Finally, we retrieve the value again using the get command.
set tutorialpro 0 900 9 memcached STORED get tutorialpro VALUE tutorialpro 0 9 memcached END append tutorialpro 0 900 5 redis STORED get tutorialpro VALUE tutorialpro 0 14 memcachedredis END
Output
If the data is added successfully, the output will be:
STORED
Output information descriptions are as follows:
- STORED: Output after successful save.
- NOT_STORED: The key does not exist in Memcached.
- CLIENT_ERROR: Execution error.