3
* Copyright 2010-2013 Horde LLC (http://www.horde.org/)
5
* See the enclosed file COPYING for license information (LGPL). If you
6
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
9
* @copyright 2010-2013 Horde LLC
10
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
15
* The abstract implementation of the cache storage driver.
17
* @author Michael Slusarz <slusarz@horde.org>
19
* @copyright 2010-2013 Horde LLC
20
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
23
abstract class Horde_Cache_Storage_Base implements Serializable
28
* @var Horde_Log_Logger
37
protected $_params = array();
42
* @param array $params Configuration parameters.
44
public function __construct(array $params = array())
46
$this->_params = array_merge($this->_params, $params);
51
* Do initialization tasks.
53
protected function _initOb()
58
* Set the logging object.
60
* @param Horde_Log_Logger $logger Log object.
62
public function setLogger($logger)
64
$this->_logger = $logger;
68
* Retrieve cached data.
70
* @param string $key Object ID to query.
71
* @param integer $lifetime Lifetime of the object in seconds.
73
* @return mixed Cached data, or false if none was found.
75
abstract public function get($key, $lifetime = 0);
78
* Store an object in the cache.
80
* @param string $key Object ID used as the caching key.
81
* @param mixed $data Data to store in the cache.
82
* @param integer $lifetime Object lifetime - i.e. the time before the
83
* data becomes available for garbage
84
* collection. If 0 will not be GC'd.
86
abstract public function set($key, $data, $lifetime = 0);
89
* Checks if a given key exists in the cache, valid for the given
92
* @param string $key Cache key to check.
93
* @param integer $lifetime Lifetime of the key in seconds.
95
* @return boolean Existence.
97
abstract public function exists($key, $lifetime = 0);
100
* Expire any existing data for the given key.
102
* @param string $key Cache key to expire.
104
* @return boolean Success or failure.
106
abstract public function expire($key);
109
* Clears all data from the cache.
111
* @throws Horde_Cache_Exception
113
abstract public function clear();
115
/* Serializable methods. */
119
public function serialize()
121
return serialize(array(
129
public function unserialize($data)
131
@list($this->_params, $this->_logger) = @unserialize($data);