aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/metastrings.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/metastrings.php')
-rw-r--r--engine/lib/metastrings.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 786e343ce..00728b1d3 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -41,10 +41,20 @@
if (in_array($string, $METASTRINGS_DEADNAME_CACHE))
return false;
+ // Experimental memcache
+ static $metastrings_memcache;
+ if ((!$metastrings_memcache) && (is_memcache_available()))
+ $metastrings_memcache = new ElggMemcache('metastrings_memcache');
+ if ($metastrings_memcache) $msfc = $metastrings_memcache->load($string);
+ if ($msfc) return $msfc;
+
$row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string='$string' limit 1");
if ($row) {
$METASTRINGS_CACHE[$row->id] = $row->string; // Cache it
+ // Attempt to memcache it if memcache is available
+ if ($metastrings_memcache) $metastrings_memcache->save($row->string, $row->id);
+
if (isset($CONFIG->debug) && $CONFIG->debug)
error_log("** Cacheing string '{$row->string}'");
@@ -123,6 +133,30 @@
{
global $CONFIG;
+ // If memcache is enabled then we need to flush it of deleted values
+ if (is_memcache_enabled())
+ {
+ $select_query = "
+ SELECT *
+ from {$CONFIG->dbprefix}metastrings where
+ (
+ (id not in (select name_id from {$CONFIG->dbprefix}metadata)) AND
+ (id not in (select value_id from {$CONFIG->dbprefix}metadata)) AND
+ (id not in (select name_id from {$CONFIG->dbprefix}annotations)) AND
+ (id not in (select value_id from {$CONFIG->dbprefix}annotations))
+ )";
+
+ $dead = get_data($select_query);
+ if ($dead)
+ {
+ static $metastrings_memcache;
+ if (!$metastrings_memcache)
+ $metastrings_memcache = new ElggMemcache('metastrings_memcache');
+ foreach ($dead as $d)
+ $metastrings_memcache->delete($d->string);
+ }
+ }
+
$query = "
DELETE
from {$CONFIG->dbprefix}metastrings where