Check if a key exists in Memcache

前端 未结 11 2319
无人共我
无人共我 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:42

    I wonder why Memcached has no special method for it. Here is what I came down to after some considerations:

    function has($key)
    {
        $m->get($key)
    
        return \Memcached::RES_NOTFOUND !== $m->getResultCode();
    }
    

提交回复
热议问题