memcache(3) 1.2.0 released...
Antony Dovgal
tony2001 at phpclub.net
Wed Jan 12 10:46:43 PST 2005
On Wed, 12 Jan 2005 10:35:54 -0800
John McCaskey <johnm at klir.com> wrote:
> The one major complaint I have with the current php oo api's (and
> possibly the Ruby api) are that they simply return FALSE (nil for
> Ruby?) for an unfound key, thus breaking the ability to store
> arbitrary binary data as I now cannot store a FALSE, or a binary
> equivalent in memcache.
Why?
Just don't store anything and you'll get the same result - FALSE.
Or store FALSE and get empty string as get() value (it seems quite
logical to me that "" == FALSE just because they _are_ equal).
I don't see any problems here, but I appreciate any help/suggestions/improvements.
> 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've missed something =)
<?php
$m = memcache_connect("localhost");
$m->set("var", FALSE);
$m->get(Array("var", "nonexistent_key"));
?>
----
bool(true)
array(1) {
["var"]=>
string(0) ""
}
----
But thanks, I just realized that I forgot to add this syntax to the docs.
> If I did this as a php5 module, maybe I'd just throw an exception...
> but alas I need to use php4.
Throwing an exception when there is no such key seems a bit scary to me.
I used to think that exceptions are throwed in case of some errors, but
missing key doesn't look as error to me.
--
Wbr,
Antony Dovgal aka tony2001
More information about the memcached
mailing list