summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Memcached_DataObject.php50
1 files changed, 10 insertions, 40 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 96f8d520b..f7cbb9d5b 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -33,41 +33,21 @@ class Memcached_DataObject extends DB_DataObject
$k = $keys[0];
unset($i);
}
- $i = self::getcached($cls, $k, $v);
+ $i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i) {
return $i;
} else {
$i = DB_DataObject::staticGet($cls, $k, $v);
if ($i) {
$i->encache();
- } else {
- self::cachenull($cls, $k, $v);
}
return $i;
}
}
- function cachenull($cls, $k, $v)
- {
- $c = self::memcache();
- if (empty($c)) {
- return;
- }
- $c->set(self::cacheKey($cls, $k, $v), null);
- }
-
- function multicachenull($cls, $kv)
- {
- $c = self::memcache();
- if (empty($c)) {
- return;
- }
- $c->set(self::multicachekey($cls, $kv), null);
- }
-
function &pkeyGet($cls, $kv)
{
- $i = self::multicache($cls, $kv);
+ $i = Memcached_DataObject::multicache($cls, $kv);
if ($i) {
return $i;
} else {
@@ -78,7 +58,6 @@ class Memcached_DataObject extends DB_DataObject
if ($i->find(true)) {
$i->encache();
} else {
- self::multicachenull($cls, $kv);
$i = null;
}
return $i;
@@ -88,9 +67,6 @@ class Memcached_DataObject extends DB_DataObject
function insert()
{
$result = parent::insert();
- if ($result) {
- $this->encache();
- }
return $result;
}
@@ -121,11 +97,11 @@ class Memcached_DataObject extends DB_DataObject
}
static function getcached($cls, $k, $v) {
- $c = self::memcache();
+ $c = Memcached_DataObject::memcache();
if (!$c) {
return false;
} else {
- return $c->get(self::cacheKey($cls, $k, $v));
+ return $c->get(Memcached_DataObject::cacheKey($cls, $k, $v));
}
}
@@ -192,23 +168,17 @@ class Memcached_DataObject extends DB_DataObject
function multicache($cls, $kv)
{
- $c = self::memcache();
+ ksort($kv);
+ $c = Memcached_DataObject::memcache();
if (!$c) {
return false;
} else {
- return $c->get(self::multicachekey($cls, $kv));
+ $pkeys = implode(',', array_keys($kv));
+ $pvals = implode(',', array_values($kv));
+ return $c->get(Memcached_DataObject::cacheKey($cls, $pkeys, $pvals));
}
}
- function multicachekey($cls, $kv)
- {
- ksort($kv);
- $pkeys = implode(',', array_keys($kv));
- $pvals = implode(',', array_values($kv));
-
- return self::cacheKey($cls, $pkeys, $pvals);
- }
-
function getSearchEngine($table)
{
require_once INSTALLDIR.'/lib/search_engines.php';
@@ -241,7 +211,7 @@ class Memcached_DataObject extends DB_DataObject
static function cachedQuery($cls, $qry, $expiry=3600)
{
- $c = self::memcache();
+ $c = Memcached_DataObject::memcache();
if (!$c) {
$inst = new $cls();
$inst->query($qry);