Check if a key exists in Memcache

前端 未结 11 2349
无人共我
无人共我 2021-02-12 15:17

How do I check in PHP if a value is stored in Memcache without fetching it? I don\'t like fetching it because the values I have set are all 1MB in size and after I fetch it, I h

11条回答
  •  故里飘歌
    2021-02-12 15:37

    I am not sure if this is of any help to you, but you can use

    Memcache::add  (  string $key  ,  mixed $var)
    

    It will return false if the key already exists.

    In case true is returned you may use

    Memcache::delete  (  string $key)
    

    to remove the key you just set. That way you won't need to fetch the data.

提交回复
热议问题