Reputation: 8640
Any idea if PHP's memcached module supports some kind of isset()
method?
Following case:
Memcached::set('foo', false);
if(Memcached::get('foo') === false) {
// Set or not set?
}
Upvotes: 2
Views: 924
Reputation: 70500
according to the documentation
if($memcached->get('var') === false && $memcached->getResultCode() == Memcached::RES_NOTFOUND){
//not set
}
You can of course extend the Memcached
object to include it, however, you can't ask if it's set without getting it (some overhead on larger values):
class YourMemcached extends Memcached {
function var_isset($var){
return $this->get($var)!==false || $this->getResultCode() != Memcached::RES_NOTFOUND;
}
}
(you can't use isset
as a method name as it's a language construct apparently).
Upvotes: 5