Memcached replace 命令

replace 仅当 key 已存在时才更新。

Beginner
Key Pointsreplace 与 add 相反:key 不存在就失败,存在才覆盖。

用法

Shell
set k 0 0 3
abc
replace k 0 0 3
xyz
get k
replace missing 0 0 3
xyz
Output
STORED
STORED
VALUE k 0 3
xyz
END
NOT_STORED
replace returns NOT_STORED for missing keys. Use set for 'upsert', replace for 'update only if exists', add for 'insert only if absent' — their existence semantics are complementary.

Friends & Partners