Latest web development tutorials

Memcached set command

Memcached set command is used tovalue (data value) stored in the specified key (key).

If you set the key already exists, this command can update the key corresponding to the original data, which is updated to achieve the role.

grammar:

The basic syntax of the command is set as follows:

set key flags exptime bytes [noreply] 
value 

Parameters are as follows:

  • key: key key-value structure key, it is used to find the cache value.
  • flags: may include a key-value pair of integer parameter, the client uses it to store additional information about the key-value pairs.
  • exptime: save key-value pairs in the cache the length of time (in seconds, 0 means forever)
  • bytes: number of bytes stored in the cache
  • noreply (optional): This parameter tells the server does not need to return data
  • value: the value stored (always located in the second row) (can be directly understood as key-value structure value)

Examples

We set the following examples:

  • key → w3big
  • flag → 0
  • exptime → 900 (in seconds)
  • bytes → 9 (the number of bytes of data storage)
  • value → memcached
set w3big 0 900 9
memcached
STORED

get w3big
VALUE w3big 0 9
memcached

END

Export

If the data set is successful, the output:

STORED

Output information Description:

  • STORED: After successfully saved output.
  • ERROR: After the failure to maintain output.