From 7ad8e2c3180e2357cbc395da18c5f9d4ad509b0a Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 23 May 2011 05:34:57 -0400
Subject: [PATCH] - Add TTL parameter to rcube_cache class (and rcmail::get_cache method)

---
 program/include/rcmail.php |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 7844b98..acd661d 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -333,7 +333,7 @@
         $this->memcache = false;
         return false;
       }
-      
+
       $this->memcache = new Memcache;
       $mc_available = 0;
       foreach ($this->config->get('memcache_hosts', array()) as $host) {
@@ -343,11 +343,11 @@
         if ($this->memcache->addServer($host, $port) && !$mc_available)
           $mc_available += intval($this->memcache->connect($host, $port));
       }
-      
+
       if (!$mc_available)
         $this->memcache = false;
     }
-    
+
     return $this->memcache;
   }
 
@@ -357,13 +357,14 @@
    *
    * @param string $name Cache identifier
    * @param string $type Cache type ('db', 'apc' or 'memcache')
+   * @param int    $ttl  Expiration time for cache items in seconds
    *
    * @return rcube_cache Cache object
    */
-  public function get_cache($name, $type)
+  public function get_cache($name, $type='db', $ttl=0)
   {
     if (!isset($this->caches[$name])) {
-      $this->caches[$name] = new rcube_cache($type, $_SESSION['user_id'], $name);
+      $this->caches[$name] = new rcube_cache($type, $_SESSION['user_id'], $name, $ttl);
     }
 
     return $this->caches[$name];

--
Gitblit v1.9.1