From 3073665cfed761dd841fbe81cf5cef15a6c7af10 Mon Sep 17 00:00:00 2001 From: SJ Date: Tue, 4 Dec 2012 22:34:15 +0100 Subject: [PATCH] added the queried metadata to memcache --- webui/model/search/search.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 9e8d91ff..e5a99286 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -439,8 +439,14 @@ class ModelSearchSearch extends Model { if(count($ids) == 0) return $messages; - $query = $this->db->query("SELECT `id`, `from`, `subject`, `piler_id`, `reference`, `size`, `spam`, `sent`, `arrived`, `attachments` FROM `" . TABLE_META . "` WHERE `id` IN ($q) $sortorder", $ids); + if(MEMCACHED_ENABLED) { + $cache_key = $this->make_cache_file_name($ids, 'meta'); + $memcache = Registry::get('memcache'); + $m = $memcache->get($cache_key); + if(isset($m['meta'])) { return unserialize($m['meta']); } + } + $query = $this->db->query("SELECT `id`, `from`, `subject`, `piler_id`, `reference`, `size`, `spam`, `sent`, `arrived`, `attachments` FROM `" . TABLE_META . "` WHERE `id` IN ($q) $sortorder", $ids); if(isset($query->rows)) { @@ -486,6 +492,10 @@ class ModelSearchSearch extends Model { } } + if(MEMCACHED_ENABLED) { + $memcache->add($cache_key, array('meta' => serialize($messages)), 0, MEMCACHED_TTL); + } + return $messages; }