Memcached replace command
Memcached replace command is used to replace an existingkey (key) value (data value).
If the key does not exist, replace fail, and you will get a responseNOT_STORED.
grammar:
The basic syntax replace command is as follows:
replace 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 → mykey
- flag → 0
- exptime → 900 (in seconds)
- bytes → 10 (the number of bytes of data storage)
- value → data_value
The following examples keys we use 'mykey' and store the corresponding value data_value. After the execution we replace the same key value 'some_other_value'.
add mykey 0 900 10 data_value STORED get mykey VALUE mykey 0 10 data_value END replace mykey 0 900 16 some_other_value get mykey VALUE mykey 0 16 some_other_value END
Export
If the data is added successfully, the output:
STORED
Output information Description:
- STORED: After successfully saved output.
- NOT_STORED: carries out replacement after failure output.