aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/elgglib.php19
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}'");