Set TTL for attachments stored in sql database

pull/84/head
Aleksander Machniak 12 years ago
parent 12f1190a62
commit df9d004cf8

@ -6,8 +6,8 @@
// to use memcache as a fallback when write-master is unavailable. // to use memcache as a fallback when write-master is unavailable.
$rcmail_config['redundant_attachments_memcache'] = false; $rcmail_config['redundant_attachments_memcache'] = false;
// When memcache is used, attachment data expires after // Attachment data expires after specied TTL time in seconds (max.2592000).
// specied TTL time in seconds (max.2592000). Default is 12 hours. // Default is 12 hours.
$rcmail_config['redundant_attachments_memcache_ttl'] = 12 * 60 * 60; $rcmail_config['redundant_attachments_cache_ttl'] = 12 * 60 * 60;
?> ?>

@ -68,13 +68,14 @@ class redundant_attachments extends filesystem_attachments
// load configuration // load configuration
$this->load_config(); $this->load_config();
$ttl = 12 * 60 * 60; // 12 hours
$ttl = $rcmail->config->get('redundant_attachments_cache_ttl', $ttl);
// Init SQL cache (disable cache data serialization) // Init SQL cache (disable cache data serialization)
$this->cache = $rcmail->get_cache($this->prefix, 'db', 0, false); $this->cache = $rcmail->get_cache($this->prefix, 'db', $ttl, false);
// Init memcache (fallback) cache // Init memcache (fallback) cache
if ($rcmail->config->get('redundant_attachments_memcache')) { if ($rcmail->config->get('redundant_attachments_memcache')) {
$ttl = 12 * 60 * 60; // 12 hours
$ttl = (int) $rcmail->config->get('redundant_attachments_memcache_ttl', $ttl);
$this->mem_cache = $rcmail->get_cache($this->prefix, 'memcache', $ttl, false); $this->mem_cache = $rcmail->get_cache($this->prefix, 'memcache', $ttl, false);
} }

@ -44,6 +44,7 @@ class rcube_config
'refresh_interval' => 'keep_alive', 'refresh_interval' => 'keep_alive',
'min_refresh_interval' => 'min_keep_alive', 'min_refresh_interval' => 'min_keep_alive',
'messages_cache_ttl' => 'message_cache_lifetime', 'messages_cache_ttl' => 'message_cache_lifetime',
'redundant_attachments_cache_ttl' => 'redundant_attachments_memcache_ttl',
); );

Loading…
Cancel
Save