1: <?php
2: /**
3: * This class provides cache storage in PHP memory.
4: * It persists only during a script run and ignores the object lifetime
5: * because of that.
6: *
7: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
8: *
9: * See the enclosed file COPYING for license information (LGPL). If you
10: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
11: *
12: * @author Gunnar Wrobel <wrobel@pardus.de>
13: * @category Horde
14: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
15: * @link http://pear.horde.org/index.php?package=Cache
16: * @package Cache
17: */
18: class Horde_Cache_Storage_Mock extends Horde_Cache_Storage_Base
19: {
20: /**
21: * The storage location for this cache.
22: *
23: * @var array
24: */
25: private $_cache = array();
26:
27: /**
28: */
29: public function get($key, $lifetime = 0)
30: {
31: return isset($this->_cache[$key])
32: ? $this->_cache[$key]
33: : false;
34: }
35:
36: /**
37: */
38: public function set($key, $data, $lifetime = 0)
39: {
40: $this->_cache[$key] = $data;
41: }
42:
43: /**
44: */
45: public function exists($key, $lifetime = 0)
46: {
47: return isset($this->_cache[$key]);
48: }
49:
50: /**
51: */
52: public function expire($key)
53: {
54: unset($this->_cache[$key]);
55: }
56:
57: /**
58: */
59: public function clear()
60: {
61: $this->_cache = array();
62: }
63:
64: }
65: