$MCACHE - rework memcached support - some rework on eaccelerator

We now have a wrapper memcached support class to handle
initial connection setup, provide the common denominator
calls, plus getforfill() and friends.

The eaccelerator class now returns false to match memcached. The
downside of this is that we cannot store booleans as a false value
is indistinguishable from a false that indicates error or 'key not
found'.
This commit is contained in:
martinlanghoff 2006-12-27 22:47:51 +00:00
parent 2142d4924f
commit f917d0ea9b
3 changed files with 150 additions and 27 deletions

View file

@ -11,6 +11,9 @@
**
** Author: Martin Langhoff <martin@catalyst.net.nz>
**
** Note: do NOT store booleans here. For compatibility with
** memcached, a false value is indistinguisable from a
** "not found in cache" response.
**/
@ -52,7 +55,7 @@ class eaccelerator {
$fn = $this->mode . '_get';
$rec = $fn($this->prefix . $key);
if (is_null($rec)) {
return null;
return false;
}
return unserialize($rec);
}
@ -85,7 +88,7 @@ class eaccelerator {
* http://marc.theaimsgroup.com/?l=git&m=116562052506776&w=2
*
* @param $key string
* @return mixed on cache hit, NULL otherwise
* @return mixed on cache hit, false otherwise
*/
function getforfill ($key) {
$get = $this->mode . '_get';
@ -98,7 +101,7 @@ class eaccelerator {
if ($lock($this->prefix . $key . '_forfill')) {
// we obtained the _forfill lock
// our caller will compute and set the value
return null;
return false;
}
// someone else has the lock
// "block" till we can get the value
@ -110,7 +113,7 @@ class eaccelerator {
return unserialize($rec);
}
}
return null;
return false;
}
/**