Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Memcached append command


May 17, 2021 Memcached



The Memcached append command is used to append data after the value (data value) of an existing key (key).

Grammar:

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

append key flags exptime bytes [noreply]
value

The parameters are described below:

  • Key: Key in the key-value structure to find cached values.
  • flags: You can include integer parameters for key value pairs, which the client uses to store additional information about key value pairs.
  • exptime: The length of time (in seconds, 0 means forever) to save key pairs in the cache
  • Bytes: The number of bytes stored in the cache
  • Noreply (optional): This parameter tells the server that no data needs to be returned
  • value: Stored value (always on the second row) (can be understood directly as value in key-value structure)

Instance

Here's an example:

  • First we store a key w3cschool in Memcached, which has a value of memcached.
  • We then use the get command to retrieve the value.
  • We then use the append command to append "redis" after the key to the value of w3cschool.
  • Finally, we use the get command to retrieve the value.
set w3cschool 0 900 9
memcached
STORED
get w3cschool
VALUE w3cschool 0 14
memcached
END
append w3cschool 0 900 5
redis
STORED
get w3cschool
VALUE w3cschool 0 14
memcachedredis
END

Output

If the data is added successfully, the output:

STORED

Output information description:

  • STORED: The output after the successful save.
  • NOT_STORED: The key does not exist on Memcached.
  • CLIENT_ERROR: Execution error.