diff options
Diffstat (limited to 'classes/Memcached_DataObject.php')
-rw-r--r-- | classes/Memcached_DataObject.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index d11bd6368..4e3cc5678 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -90,17 +90,16 @@ class Memcached_DataObject extends DB_DataObject unset($i); } $i = Memcached_DataObject::getcached($cls, $k, $v); - if ($i !== false) { // false == cache miss - return $i; - } else { + if ($i === false) { // false == cache miss $i = DB_DataObject::factory($cls); if (empty($i)) { - return false; + $i = false; + return $i; } $result = $i->get($k, $v); if ($result) { + // Hit! $i->encache(); - return $i; } else { // save the fact that no such row exists $c = self::memcache(); @@ -108,12 +107,16 @@ class Memcached_DataObject extends DB_DataObject $ck = self::cachekey($cls, $k, $v); $c->set($ck, null); } - return false; + $i = false; } } + return $i; } - function &pkeyGet($cls, $kv) + /** + * @fixme Should this return false on lookup fail to match staticGet? + */ + function pkeyGet($cls, $kv) { $i = Memcached_DataObject::multicache($cls, $kv); if ($i !== false) { // false == cache miss @@ -143,7 +146,9 @@ class Memcached_DataObject extends DB_DataObject function insert() { $result = parent::insert(); - $this->encache(); // in case of cached negative lookups + if ($result) { + $this->encache(); // in case of cached negative lookups + } return $result; } |