From: Evan Prodromou Date: Fri, 1 Jan 2010 21:20:25 +0000 (-1000) Subject: Merge branch 'master' into 0.9.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a9d835920824c48caef2a66686d6605ff54586b3;hp=-c;p=quix0rs-gnu-social.git Merge branch 'master' into 0.9.x Conflicts: classes/Memcached_DataObject.php --- a9d835920824c48caef2a66686d6605ff54586b3 diff --combined classes/Memcached_DataObject.php index be8137573d,cf7fb4340a..4f81bef75c --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@@ -37,15 -37,6 +37,15 @@@ class Memcached_DataObject extends DB_D } } + /** + * Wrapper for DB_DataObject's static lookup using memcached + * as backing instead of an in-process cache array. + * + * @param string $cls classname of object type to load + * @param mixed $k key field name, or value for primary key + * @param mixed $v key field value, or leave out for primary key lookup + * @return mixed Memcached_DataObject subtype or false + */ function &staticGet($cls, $k, $v=null) { if (is_null($v)) { @@@ -60,18 -51,17 +60,17 @@@ if ($i) { return $i; } else { - $i = DB_DataObject::staticGet($cls, $k, $v); - if ($i) { - // DB_DataObject's in-process lookup cache interferes with GC - // to cause massive memory leaks in long-running processes. - if (php_sapi_name() == 'cli') { - $i->_clear_cache(); - } - - // Now store it into the shared memcached, if present... + $i = DB_DataObject::factory($cls); + if (empty($i)) { + return null; + } + $result = $i->get($k, $v); + if ($result) { $i->encache(); + return $i; + } else { + return null; } - return $i; } } @@@ -263,6 -253,18 +262,18 @@@ return new ArrayWrapper($cached); } + function cleanup() + { + global $_DB_DATAOBJECT; + + if (isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) { + unset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]); + } + if (isset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid])) { + unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]); + } + } + // We overload so that 'SET NAMES "utf8"' is called for // each connection