added the queried metadata to memcache

This commit is contained in:
SJ 2012-12-04 22:34:15 +01:00
parent 1feb01384f
commit 3073665cfe

View File

@ -439,8 +439,14 @@ class ModelSearchSearch extends Model {
if(count($ids) == 0) return $messages; 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)) { 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; return $messages;
} }