Memcached append command

The Memcached append command is used to, for an existingkeyofvalue,append data after it.

Syntax:

The basic syntax format of the append command is as follows:

append key flags exptime bytes [noreply]
value

The parameter descriptions are as follows:

  • key:The key in the key-value structure, used to look up the cached value.
  • flags: An integer parameter that can include key-value pairs; the client uses it to store additional information about the key-value pair.
  • exptime: The length of time to save the key-value pair in the cache (in seconds; 0 means forever)
  • bytes: The number of bytes to store 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 theappendcommand to append "redis" after 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
append example 0 900 5
redis
STORED
get example
VALUE example 0 14
memcachedredis
END

Output

If the data is added successfully, the output is:

STORED

Output information description:

  • STORED: Output after a successful save.
  • NOT_STORED: This key does not exist in Memcached.
  • CLIENT_ERROR: Execution error.
Other extensions