memcache(3) 1.2.0 released...

Sean Chittenden sean at chittenden.org
Wed Jan 12 12:07:42 PST 2005


>>> Perhaps, I'll always return as an array('key'=>'value', ...,
>>> 'keyn'=>'valuen') and the way to determine a miss is simply that the
>>> key
>>> does not exist at all, and then NULL or FALSE are valid data from the
>>> cache.
>>
>> You could do that.  Actually, that's the best way to handle the
>> above... didn't think about that.
>
> Yep it looks like this is what I'll do, add's a little overhead in
> creating the array and checking for the existance of a key, but the
> reliability is important to me.

Be sure to have multiple get methods.  Memcache#get() returns just the 
key in a scalar form.  Memcache#get_a() returns a parallel array to 
what you put in as arguments with nil filled in at the appropriate 
array index.  Memcache#get_h() returns a hash of key->value pairs.  
Since arrays and hashes are the same in PHP, you probably want to have 
a get() method, and a get_array() method.  Having to deal with arrays 
if you only want one value is a huge PITA.  -sc

-- 
Sean Chittenden



More information about the memcached mailing list