From 621d7582253c9684921cb6d4d44014d6348b860b Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 27 Apr 2010 05:04:43 +0200 Subject: [PATCH] Now that Horde_Cache is empty we can make it an interface. 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 | 46 +++++++++++++++++++++++++++++++- framework/Cache/lib/Horde/Cache/Base.php | 46 +------------------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/framework/Cache/lib/Horde/Cache.php b/framework/Cache/lib/Horde/Cache.php index ee39a5b03..b2a1b9f95 100644 --- a/framework/Cache/lib/Horde/Cache.php +++ b/framework/Cache/lib/Horde/Cache.php @@ -14,6 +14,50 @@ * @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); } diff --git a/framework/Cache/lib/Horde/Cache/Base.php b/framework/Cache/lib/Horde/Cache/Base.php index 5b2a46821..01c1505e2 100644 --- a/framework/Cache/lib/Horde/Cache/Base.php +++ b/framework/Cache/lib/Horde/Cache/Base.php @@ -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. -- 2.11.0