Simplify Horde_Cache binder to a simple injector factory
authorChuck Hagenbuch <chuck@horde.org>
Sun, 3 Oct 2010 01:59:23 +0000 (21:59 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 3 Oct 2010 02:00:25 +0000 (22:00 -0400)
19 files changed:
framework/Cache/lib/Horde/Cache.php
framework/Cache/lib/Horde/Cache/Apc.php
framework/Cache/lib/Horde/Cache/Base.php [deleted file]
framework/Cache/lib/Horde/Cache/Eaccelerator.php
framework/Cache/lib/Horde/Cache/File.php
framework/Cache/lib/Horde/Cache/Memcache.php
framework/Cache/lib/Horde/Cache/Mock.php
framework/Cache/lib/Horde/Cache/Null.php
framework/Cache/lib/Horde/Cache/Session.php
framework/Cache/lib/Horde/Cache/Sql.php
framework/Cache/lib/Horde/Cache/Stack.php
framework/Cache/lib/Horde/Cache/Xcache.php
framework/Cache/package.xml
framework/Core/lib/Horde/Core/Binder/Cache.php [deleted file]
framework/Core/lib/Horde/Core/Binder/CacheFactory.php [deleted file]
framework/Core/lib/Horde/Core/Factory/Cache.php
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml
imp/lib/Injector/Binder/Imaptree.php

index 5141a4c..6cbc889 100644 (file)
@@ -1,8 +1,7 @@
 <?php
 /**
- * The Horde_Cache:: class provides a common abstracted interface into
- * the various caching backends.  It also provides functions for
- * checking in, retrieving, and flushing a cache.
+ * The Horde_Cache:: class provides the abstract class definition for
+ * Horde_Cache drivers.
  *
  * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
  *
  *
  * @author   Anil Madhavapeddy <anil@recoil.org>
  * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @author   Michael Slusarz <slusarz@horde.org>
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache
+abstract class Horde_Cache
 {
     /**
-     * Attempts to return a concrete instance based on $driver.
+     * Cache parameters.
      *
-     * @param string $driver  The type of concrete subclass to
-     *                        return. The class name is based on the storage
-     *                        driver ($driver). The code is dynamically
-     *                        included.
-     * @param array $params   A hash containing any additional configuration
-     *                        or connection parameters a subclass might need.
+     * @var array
+     */
+    protected $_params = array(
+        'lifetime' => 86400,
+        'prefix' => '',
+    );
+
+    /**
+     * Logger.
      *
-     * @return Horde_Cache_Base  The newly created concrete instance.
-     * @throws Horde_Cache_Exception
+     * @var Horde_Log_Logger
      */
-    static public function factory($driver, array $params = array())
+    protected $_logger;
+
+    /**
+     * Construct a new Horde_Cache object.
+     *
+     * @param array $params  Parameter array:
+     * <pre>
+     * 'lifetime' - (integer) Lifetime of data, in seconds.
+     *              DEFAULT: 86400 seconds
+     * 'logger' - (Horde_Log_Logger) Log object to use for log/debug messages.
+     * </pre>
+     */
+    public function __construct($params = array())
     {
-        $driver = ucfirst(basename($driver));
-        $class = __CLASS__ . '_' . $driver;
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+            unset($params['logger']);
+        }
+
+        $this->_params = array_merge($this->_params, $params);
+    }
 
-        if (!class_exists($class)) {
-            $class = __CLASS__ . '_Null';
+    /**
+     * Attempts to directly output a cached object.
+     *
+     * @param string $key        Object ID to query.
+     * @param integer $lifetime  Lifetime of the object in seconds.
+     *
+     * @return boolean  True if output or false if no object was found.
+     */
+    public function output($key, $lifetime = 1)
+    {
+        $data = $this->get($key, $lifetime);
+        if ($data === false) {
+            return false;
         }
 
-        return new $class($params);
+        echo $data;
+        return true;
     }
 
+    /**
+     * Attempts to retrieve a cached object and return it to the
+     * caller.
+     *
+     * @param string $key        Object ID to query.
+     * @param integer $lifetime  Lifetime of the object in seconds.
+     *
+     * @return mixed  Cached data, or false if none was found.
+     */
+    abstract public function get($key, $lifetime = 1);
+
+    /**
+     * Attempts to store an object in the cache.
+     *
+     * @param string $key        Object ID used as the caching key.
+     * @param mixed $data        Data to store in the cache.
+     * @param integer $lifetime  Object lifetime - i.e. the time before the
+     *                           data becomes available for garbage
+     *                           collection.  If null use the default Horde GC
+     *                           time.  If 0 will not be GC'd.
+     *
+     * @throws Horde_Cache_Exception
+     */
+    abstract public function set($key, $data, $lifetime = null);
+
+    /**
+     * Checks if a given key exists in the cache, valid for the given
+     * lifetime.
+     *
+     * @param string $key        Cache key to check.
+     * @param integer $lifetime  Lifetime of the key in seconds.
+     *
+     * @return boolean  Existence.
+     */
+    abstract public function exists($key, $lifetime = 1);
+
+    /**
+     * Expire any existing data for the given key.
+     *
+     * @param string $key  Cache key to expire.
+     *
+     * @return boolean  Success or failure.
+     */
+    abstract public function expire($key);
+
+    /**
+     * Determine the default lifetime for data.
+     *
+     * @param mixed $lifetime  The lifetime to use or null for default.
+     *
+     * @return integer  The lifetime, in seconds.
+     */
+    protected function _getLifetime($lifetime)
+    {
+        return is_null($lifetime) ? $this->_params['lifetime'] : $lifetime;
+    }
 }
index 4c7828d..84b41e3 100644 (file)
@@ -12,7 +12,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Apc extends Horde_Cache_Base
+class Horde_Cache_Apc extends Horde_Cache
 {
     /**
      * Attempts to retrieve a piece of cached data and return it to
@@ -104,5 +104,4 @@ class Horde_Cache_Apc extends Horde_Cache_Base
             apc_delete($key . '_expire');
         }
     }
-
 }
diff --git a/framework/Cache/lib/Horde/Cache/Base.php b/framework/Cache/lib/Horde/Cache/Base.php
deleted file mode 100644 (file)
index 2067a1f..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-/**
- * The Horde_Cache_Base:: class provides the abstract class definition for
- * Horde_Cache drivers.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Anil Madhavapeddy <anil@recoil.org>
- * @author   Chuck Hagenbuch <chuck@horde.org>
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package  Cache
- */
-abstract class Horde_Cache_Base
-{
-    /**
-     * Cache parameters.
-     *
-     * @var array
-     */
-    protected $_params = array(
-        'lifetime' => 86400,
-        'prefix' => '',
-    );
-
-    /**
-     * Logger.
-     *
-     * @var Horde_Log_Logger
-     */
-    protected $_logger;
-
-    /**
-     * Construct a new Horde_Cache object.
-     *
-     * @param array $params  Parameter array:
-     * <pre>
-     * 'lifetime' - (integer) Lifetime of data, in seconds.
-     *              DEFAULT: 86400 seconds
-     * 'logger' - (Horde_Log_Logger) Log object to use for log/debug messages.
-     * </pre>
-     */
-    public function __construct($params = array())
-    {
-        if (isset($params['logger'])) {
-            $this->_logger = $params['logger'];
-            unset($params['logger']);
-        }
-
-        $this->_params = array_merge($this->_params, $params);
-    }
-
-    /**
-     * Attempts to directly output a cached object.
-     *
-     * @param string $key        Object ID to query.
-     * @param integer $lifetime  Lifetime of the object in seconds.
-     *
-     * @return boolean  True if output or false if no object was found.
-     */
-    public function output($key, $lifetime = 1)
-    {
-        $data = $this->get($key, $lifetime);
-        if ($data === false) {
-            return false;
-        }
-
-        echo $data;
-        return true;
-    }
-
-    /**
-     * Attempts to retrieve a cached object and return it to the
-     * caller.
-     *
-     * @param string $key        Object ID to query.
-     * @param integer $lifetime  Lifetime of the object in seconds.
-     *
-     * @return mixed  Cached data, or false if none was found.
-     */
-    abstract public function get($key, $lifetime = 1);
-
-    /**
-     * Attempts to store an object in the cache.
-     *
-     * @param string $key        Object ID used as the caching key.
-     * @param mixed $data        Data to store in the cache.
-     * @param integer $lifetime  Object lifetime - i.e. the time before the
-     *                           data becomes available for garbage
-     *                           collection.  If null use the default Horde GC
-     *                           time.  If 0 will not be GC'd.
-     *
-     * @throws Horde_Cache_Exception
-     */
-    abstract public function set($key, $data, $lifetime = null);
-
-    /**
-     * Checks if a given key exists in the cache, valid for the given
-     * lifetime.
-     *
-     * @param string $key        Cache key to check.
-     * @param integer $lifetime  Lifetime of the key in seconds.
-     *
-     * @return boolean  Existence.
-     */
-    abstract public function exists($key, $lifetime = 1);
-
-    /**
-     * Expire any existing data for the given key.
-     *
-     * @param string $key  Cache key to expire.
-     *
-     * @return boolean  Success or failure.
-     */
-    abstract public function expire($key);
-
-    /**
-     * Determine the default lifetime for data.
-     *
-     * @param mixed $lifetime  The lifetime to use or null for default.
-     *
-     * @return integer  The lifetime, in seconds.
-     */
-    protected function _getLifetime($lifetime)
-    {
-        return is_null($lifetime) ? $this->_params['lifetime'] : $lifetime;
-    }
-
-}
index c919654..6e1501e 100644 (file)
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Eaccelerator extends Horde_Cache_Base
+class Horde_Cache_Eaccelerator extends Horde_Cache
 {
-     /**
-      * Construct a new Horde_Cache object.
-      *
-      * @param array $params  Parameter array.
-      * @throws Horde_Cache_Exception
-      */
+    /**
+     * Construct a new Horde_Cache object.
+     *
+     * @param array $params  Parameter array.
+     * @throws Horde_Cache_Exception
+     */
     public function __construct($params = array())
     {
         if (!function_exists('eaccelerator_gc')) {
@@ -119,5 +119,4 @@ class Horde_Cache_Eaccelerator extends Horde_Cache_Base
             eaccelerator_rm($key . '_expire');
         }
     }
-
 }
index d4cf07c..b7022a5 100644 (file)
@@ -13,7 +13,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_File extends Horde_Cache_Base
+class Horde_Cache_File extends Horde_Cache
 {
     /**
      * The location of the temp directory.
@@ -299,6 +299,4 @@ class Horde_Cache_File extends Horde_Cache_Base
         }
         $d->close();
     }
-
 }
-
index e9073eb..198fc2f 100644 (file)
@@ -14,7 +14,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Memcache extends Horde_Cache_Base
+class Horde_Cache_Memcache extends Horde_Cache
 {
     /**
      * Memcache object.
@@ -151,5 +151,4 @@ class Horde_Cache_Memcache extends Horde_Cache_Base
 
         return $this->_memcache->delete($key);
     }
-
 }
index 872ba37..8d256ab 100644 (file)
@@ -15,7 +15,7 @@
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Cache
  */
-class Horde_Cache_Mock extends Horde_Cache_Base
+class Horde_Cache_Mock extends Horde_Cache
 {
     /**
      * The storage location for this cache.
index 2726702..93af164 100644 (file)
@@ -12,7 +12,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Null extends Horde_Cache_Base
+class Horde_Cache_Null extends Horde_Cache
 {
     /**
      * Attempts to retrieve a piece of cached data and return it to
@@ -69,5 +69,4 @@ class Horde_Cache_Null extends Horde_Cache_Base
     {
         return false;
     }
-
 }
index 260b56f..ea8c866 100644 (file)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @package  Cache
  */
-class Horde_Cache_Session extends Horde_Cache_Base
+class Horde_Cache_Session extends Horde_Cache
 {
     /**
      * Pointer to the session entry.
@@ -123,5 +123,4 @@ class Horde_Cache_Session extends Horde_Cache_Base
 
         return false;
     }
-
 }
index e5ab165..2846f8e 100644 (file)
@@ -28,7 +28,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Sql extends Horde_Cache_Base
+class Horde_Cache_Sql extends Horde_Cache
 {
     /**
      * Handle for the current database connection.
@@ -252,5 +252,4 @@ class Horde_Cache_Sql extends Horde_Cache_Base
 
         return true;
     }
-
 }
index d075b9c..2385a96 100644 (file)
@@ -13,7 +13,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Stack extends Horde_Cache_Base
+class Horde_Cache_Stack extends Horde_Cache
 {
     /**
      * Stack of cache drivers.
@@ -27,12 +27,9 @@ class Horde_Cache_Stack extends Horde_Cache_Base
      *
      * @param array $params  Parameters:
      * <pre>
-     * 'stack' - (array) [REQUIRED] A list of cache drivers to loop
+     * 'stack' - (array) [REQUIRED] An array of Cache instances to loop
      *           through, in order of priority. The last entry is considered
      *           the 'master' driver, for purposes of writes.
-     *           Each value should contain an array with two keys: 'driver', a
-     *           string value with the Cache driver to use, and 'params',
-     *           containing any parameters needed by this driver.
      * </pre>
      *
      * @throws InvalidArgumentException
@@ -42,13 +39,9 @@ class Horde_Cache_Stack extends Horde_Cache_Base
         if (!isset($params['stack'])) {
             throw new InvalidArgumentException('Missing stack parameter.');
         }
-
-        foreach ($params['stack'] as $val) {
-            $this->_stack[] = Horde_Cache::factory($val['driver'], $val['params']);
-        }
+        $this->_stack[] = $params['stack'];
 
         unset($params['stack']);
-
         parent::__construct($params);
     }
 
@@ -152,5 +145,4 @@ class Horde_Cache_Stack extends Horde_Cache_Base
 
         return $success;
     }
-
 }
index bd43061..b4635c9 100644 (file)
@@ -12,7 +12,7 @@
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache_Xcache extends Horde_Cache_Base
+class Horde_Cache_Xcache extends Horde_Cache
 {
     /**
      * Attempts to retrieve a piece of cached data and return it to the caller.
@@ -106,5 +106,4 @@ class Horde_Cache_Xcache extends Horde_Cache_Base
             xcache_unset($key);
         }
     }
-
 }
index 90c5a62..7b622df 100644 (file)
@@ -34,7 +34,7 @@ Performance Suite&apos;s content cache), memcached, or an SQL table.
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
  <notes>* Added Horde_Cache_Session::.
- * Horde_Cache_Base::set() no longer returns a boolean result.
+ * Horde_Cache::set() no longer returns a boolean result.
  * Added Horde_Cache_Exception::.
  * Removed dependency on Horde Core.
  * Initial Horde 4 package.</notes>
@@ -47,7 +47,6 @@ Performance Suite&apos;s content cache), memcached, or an SQL table.
     <dir name="Horde">
      <dir name="Cache">
       <file name="Apc.php" role="php" />
-      <file name="Base.php" role="php" />
       <file name="Eaccelerator.php" role="php" />
       <file name="Exception.php" role="php" />
       <file name="File.php" role="php" />
@@ -105,7 +104,6 @@ Performance Suite&apos;s content cache), memcached, or an SQL table.
  <phprelease>
   <filelist>
    <install name="lib/Horde/Cache/Apc.php" as="Horde/Cache/Apc.php" />
-   <install name="lib/Horde/Cache/Base.php" as="Horde/Cache/Base.php" />
    <install name="lib/Horde/Cache/Eaccelerator.php" as="Horde/Cache/Eaccelerator.php" />
    <install name="lib/Horde/Cache/Exception.php" as="Horde/Cache/Exception.php" />
    <install name="lib/Horde/Cache/File.php" as="Horde/Cache/File.php" />
diff --git a/framework/Core/lib/Horde/Core/Binder/Cache.php b/framework/Core/lib/Horde/Core/Binder/Cache.php
deleted file mode 100644 (file)
index b8366d9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-/**
- * @category Horde
- * @package  Core
- */
-class Horde_Core_Binder_Cache implements Horde_Injector_Binder
-{
-    public function create(Horde_Injector $injector)
-    {
-        $cache = new Horde_Core_Factory_Cache($injector);
-        return $cache->getCache();
-    }
-
-    public function equals(Horde_Injector_Binder $binder)
-    {
-        return false;
-    }
-
-}
diff --git a/framework/Core/lib/Horde/Core/Binder/CacheFactory.php b/framework/Core/lib/Horde/Core/Binder/CacheFactory.php
deleted file mode 100644 (file)
index 53f7d44..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/**
- * @category Horde
- * @package  Core
- */
-class Horde_Core_Binder_CacheFactory implements Horde_Injector_Binder
-{
-    public function create(Horde_Injector $injector)
-    {
-        return new Horde_Core_Factory_Cache($injector);
-    }
-
-    public function equals(Horde_Injector_Binder $binder)
-    {
-        return false;
-    }
-
-}
index 64baccf..237116c 100644 (file)
 class Horde_Core_Factory_Cache
 {
     /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Singleton instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
      * Return the Horde_Cache:: instance.
      *
      * @param array $opts  Options:
@@ -64,7 +40,7 @@ class Horde_Core_Factory_Cache
      * @return Horde_Cache_Base  The singleton instance.
      * @throws Horde_Cache_Exception
      */
-    public function getCache(array $opts = array())
+    public function create(Horde_Injector $injector)
     {
         $driver = empty($GLOBALS['conf']['cache']['driver'])
             ? 'Null'
@@ -73,52 +49,52 @@ class Horde_Core_Factory_Cache
             $driver = 'Null';
         }
 
-        if (($driver == 'Null') && !empty($opts['session'])) {
-            $driver = 'Session';
+        $params = Horde::getDriverConfig('cache', $driver);
+        if (isset($GLOBALS['conf']['cache']['default_lifetime'])) {
+            $params['lifetime'] = $GLOBALS['conf']['cache']['default_lifetime'];
         }
 
-        if (!isset($this->_instances[$driver])) {
-            $params = Horde::getDriverConfig('cache', $driver);
-            if (isset($GLOBALS['conf']['cache']['default_lifetime'])) {
-                $params['lifetime'] = $GLOBALS['conf']['cache']['default_lifetime'];
-            }
+        $logger = $injector->getInstance('Horde_Log_Logger');
+        $params['logger'] = $logger;
 
-            $logger = $this->_injector->getInstance('Horde_Log_Logger');
-            $params['logger'] = $logger;
+        $base_params = $params;
 
-            $base_params = $params;
+        if (strcasecmp($driver, 'Memcache') === 0) {
+            $params['memcache'] = $injector->getInstance('Horde_Memcache');
+        } elseif (strcasecmp($driver, 'Sql') === 0) {
+            $params['db'] = $injector->getInstance('Horde_Db')->getDb('horde', 'cache');
+        }
 
-            if (strcasecmp($driver, 'Memcache') === 0) {
-                $params['memcache'] = $this->_injector->getInstance('Horde_Memcache');
-            } elseif (strcasecmp($driver, 'Sql') === 0) {
-                $params['db'] = $this->_injector->getInstance('Horde_Db')->getDb('horde', 'cache');
+        if (!empty($GLOBALS['conf']['cache']['use_memorycache']) &&
+            ((strcasecmp($driver, 'Sql') === 0) ||
+             (strcasecmp($driver, 'File') === 0))) {
+            if (strcasecmp($GLOBALS['conf']['cache']['use_memorycache'], 'Memcache') === 0) {
+                $base_params['memcache'] = $injector->getInstance('Horde_Memcache');
             }
 
-            if (!empty($GLOBALS['conf']['cache']['use_memorycache']) &&
-                ((strcasecmp($driver, 'Sql') === 0) ||
-                 (strcasecmp($driver, 'File') === 0))) {
-                if (strcasecmp($GLOBALS['conf']['cache']['use_memorycache'], 'Memcache') === 0) {
-                    $base_params['memcache'] = $this->_injector->getInstance('Horde_Memcache');
-                }
+            $class1 = $this->_driverToClassname($GLOBALS['conf']['cache']['use_memorycache']);
+            $class2 = $this->_driverToClassname($driver);
+            $params = array(
+                'stack' => array(
+                    new $class1($base_params),
+                    new $class2($params),
+                )
+            );
+            $driver = 'Stack';
+        }
 
-                $params = array(
-                    'stack' => array(
-                        array(
-                            'driver' => $GLOBALS['conf']['cache']['use_memorycache'],
-                            'params' => $base_params
-                        ),
-                        array(
-                            'driver' => $driver,
-                            'params' => $params
-                        )
-                    )
-                );
-                $driver = 'Stack';
-            }
+        $classname = $this->_driverToClassname($driver);
+        return new $classname($params);
+    }
 
-            $this->_instances[$driver] = Horde_Cache::factory($driver, $params);
+    protected function _driverToClassname($driver)
+    {
+        $driver = ucfirst(basename($driver));
+        $classname = 'Horde_Cache_' . $driver;
+        if (!class_exists($classname)) {
+            $classname = 'Horde_Cache_Null';
         }
 
-        return $this->_instances[$driver];
+        return $classname;       
     }
 }
index 08ee18c..b814d50 100644 (file)
@@ -267,7 +267,6 @@ class Horde_Registry
             'Horde_Alarm' => 'Horde_Core_Binder_Alarm',
             'Horde_Auth_Factory' => 'Horde_Core_Binder_AuthFactory',
             // 'Horde_Browser' - initialized below
-            'Horde_Cache_Factory' => 'Horde_Core_Binder_CacheFactory',
             'Horde_Core_Auth_Signup' => 'Horde_Core_Binder_AuthSignup',
             'Horde_Crypt' => 'Horde_Core_Binder_Crypt',
             'Horde_Data' => 'Horde_Core_Binder_Data',
@@ -308,7 +307,7 @@ class Horde_Registry
         $factories = array(
             'Horde_Cache' => array(
                 'Horde_Core_Factory_Cache',
-                'getCache',
+                'create',
             ),
             'Horde_Controller_Request' => array(
                 'Horde_Core_Factory_Request',
index ead3bcd..7c4380a 100644 (file)
@@ -112,7 +112,6 @@ Application Framework.</description>
        <file name="Alarm.php" role="php" />
        <file name="AuthFactory.php" role="php" />
        <file name="AuthSignup.php" role="php" />
-       <file name="CacheFactory.php" role="php" />
        <file name="Crypt.php" role="php" />
        <file name="Data.php" role="php" />
        <file name="Db.php" role="php" />
@@ -434,7 +433,6 @@ Application Framework.</description>
    <install as="Horde/Core/Binder/Alarm.php" name="lib/Horde/Core/Binder/Alarm.php" />
    <install as="Horde/Core/Binder/AuthFactory.php" name="lib/Horde/Core/Binder/AuthFactory.php" />
    <install as="Horde/Core/Binder/AuthSignup.php" name="lib/Horde/Core/Binder/AuthSignup.php" />
-   <install as="Horde/Core/Binder/CacheFactory.php" name="lib/Horde/Core/Binder/CacheFactory.php" />
    <install as="Horde/Core/Binder/Crypt.php" name="lib/Horde/Core/Binder/Crypt.php" />
    <install as="Horde/Core/Binder/Data.php" name="lib/Horde/Core/Binder/Data.php" />
    <install as="Horde/Core/Binder/Db.php" name="lib/Horde/Core/Binder/Db.php" />
index 004ce19..7ee2bf9 100644 (file)
@@ -37,7 +37,10 @@ class IMP_Injector_Binder_Imaptree implements Horde_Injector_Binder
             /* Since IMAP tree generation is so expensive/time-consuming,
              * fallback to storing in the session even if no permanent cache
              * backend is setup. */
-            $cache = $injector->getInstance('Horde_Cache_Factory')->getCache(array('session' => true));
+            $cache = $injector->getInstance('Horde_Cache');
+            if ($cache instanceof Horde_Cache_Null) {
+                $cache = $injector->getInstance('Horde_Cache_Session');
+            }
             try {
                 $instance = @unserialize($cache->get($_SESSION['imp']['cache']['tree'], 86400));
             } catch (Exception $e) {
@@ -61,7 +64,10 @@ class IMP_Injector_Binder_Imaptree implements Horde_Injector_Binder
     {
         /* Only need to store the object if the tree has changed. */
         if ($instance->changed) {
-            $cache = $this->_injector->getInstance('Horde_Cache_Factory')->getCache(array('session' => true));
+            $cache = $this->_injector->getInstance('Horde_Cache');
+            if ($cache instanceof Horde_Cache_Null) {
+                $cache = $this->_injector->getInstance('Horde_Cache_Session');
+            }
             $cache->set($_SESSION['imp']['cache']['tree'], serialize($instance), 86400);
         }
     }
@@ -70,5 +76,4 @@ class IMP_Injector_Binder_Imaptree implements Horde_Injector_Binder
     {
         return false;
     }
-
 }