Now that Horde_Cache is empty we can make it an interface.
authorGunnar Wrobel <p@rdus.de>
Tue, 27 Apr 2010 03:04:43 +0000 (05:04 +0200)
committerGunnar Wrobel <wrobel@temple.(none)>
Tue, 27 Apr 2010 05:34:50 +0000 (07:34 +0200)
Throughout the application we refer to "an instance of Horde_Cache"
and we actually bind the cache to "Horde_Cache" in the injector. The
natural choice is to define it as the interface of the class.

framework/Cache/lib/Horde/Cache.php
framework/Cache/lib/Horde/Cache/Base.php

index ee39a5b..b2a1b9f 100644 (file)
  * @category Horde
  * @package  Cache
  */
-class Horde_Cache
+interface Horde_Cache
 {
+    /**
+     * 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.
+     */
+    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.
+     *
+     * @return boolean  True on success, false on failure.
+     */
+    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.
+     */
+    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.
+     */
+    public function expire($key);
 }
index 5b2a468..01c1505 100644 (file)
@@ -15,6 +15,7 @@
  * @package  Cache
  */
 abstract class Horde_Cache_Base
+implements Horde_Cache
 {
     /**
      * Cache parameters.
@@ -53,51 +54,6 @@ abstract class Horde_Cache_Base
     }
 
     /**
-     * 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.
-     *
-     * @return boolean  True on success, false on failure.
-     */
-    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);
-
-    /**
      * Attempts to directly output a cached object.
      *
      * @param string $key        Object ID to query.