Memcached prepend 命令
prepend 在已有值头部插入数据。
Key Pointsprepend 与 append 对称,把数据拼到值的最前面。
用法
Shell
set buf 0 0 3
xyz
prepend buf 0 0 2
ab
get bufOutput
STORED
STORED
VALUE buf 0 5
abxyz
ENDappend/prepend are not atomic — concurrent clients appending can clobber each other. For atomic accumulation use CAS or application-level locking.
用法
Shell
set buf 0 0 3
xyz
prepend buf 0 0 2
ab
get bufOutput
STORED
STORED
VALUE buf 0 5
abxyz
ENDappend/prepend 是非原子的——高并发下多个客户端同时追加可能互相覆盖部分内容。需要原子累积用 CAS,或回到应用层加锁。