diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-07 14:18:57 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-07 14:18:57 +0000 |
commit | 199ddd8e76edd04d6f62ef2e4672c693df17953b (patch) | |
tree | 52d466b29f39c0e5a3561108e4e0af0594dd65ac | |
parent | 8c1f69518594b5fea58dea9ffa7dde6ac0f1dad6 (diff) | |
download | elgg-199ddd8e76edd04d6f62ef2e4672c693df17953b.tar.gz elgg-199ddd8e76edd04d6f62ef2e4672c693df17953b.tar.bz2 |
Refs #529: Experimental memcaching on datalists
git-svn-id: https://code.elgg.org/elgg/trunk@2423 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/elgglib.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 836064060..addcf930e 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1506,9 +1506,20 @@ $name = sanitise_string($name); if (isset($DATALIST_CACHE[$name])) return $DATALIST_CACHE[$name]; + + // If memcache enabled then cache value in memcache + static $datalist_memcache; + if ((!$datalist_memcache) && (is_memcache_available())) + $datalist_memcache = new ElggMemcache('datalist_memcache'); + if ($datalist_memcache) $value = $datalist_memcache->load($name); + if ($value) return $value; if ($row = get_data_row("SELECT value from {$CONFIG->dbprefix}datalists where name = '{$name}' limit 1")) { - $DATALIST_CACHE[$name] = $row->value;
+ $DATALIST_CACHE[$name] = $row->value; + + // Cache it if memcache is available + if ($datalist_memcache) $datalist_memcache->save($name, $row-value); +
return $row->value;
}
return false;
@@ -1528,6 +1539,12 @@ $name = sanitise_string($name);
$value = sanitise_string($value); + + // If memcache is available then invalidate the cached copy + static $datalist_memcache; + if ((!$datalist_memcache) && (is_memcache_available())) + $datalist_memcache = new ElggMemcache('datalist_memcache'); + if ($datalist_memcache) $value = $datalist_memcache->delete($name); //delete_data("delete from {$CONFIG->dbprefix}datalists where name = '{$name}'");
insert_data("INSERT into {$CONFIG->dbprefix}datalists set name = '{$name}', value = '{$value}' ON DUPLICATE KEY UPDATE value='{$value}'"); |