memcache缓存命中深入理解转载

http://www.iteye.com/topic/225692

memcache的方法有

add,set,replace,get,delete,getstats,increment,decrement,close,

上面的add是在之前key对应的value中添加新的内容,set是在之前key对应的value设置新的内容,覆盖之前的内容。

set、add和replace的区别是什么?

set:http://php.net/manual/en/memcache.set.php

add:http://php.net/manual/en/memcache.add.php

replace:http://php.net/manual/en/memcache.replace.php

Replace value of the existing item

Memcache::replace() should be used to replace value of existing item with key

replace使用时key值对应的item必须存在。如果不存在,返回false。可以用set代替。

Memcache::add() stores variable var with key only if such key doesn't exist at the server yet.

必须key值不存在才能使用add。

原文地址:https://www.cnblogs.com/usual2013blog/p/3863456.html