~ubuntu-branches/ubuntu/wily/php-horde-cache/wily

« back to all changes in this revision

Viewing changes to Horde_Cache-2.2.1/lib/Horde/Cache/Storage/Mock.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2013-10-08 18:54:29 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20131008185429-8r3ao97k5z15l325
Tags: 2.3.0-1
New upstream version 2.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Copyright 2010-2013 Horde LLC (http://www.horde.org/)
4
 
 *
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.
7
 
 *
8
 
 * @category  Horde
9
 
 * @copyright 2010-2013 Horde LLC
10
 
 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
11
 
 * @link      http://pear.horde.org/index.php?package=Cache
12
 
 * @package   Cache
13
 
 */
14
 
 
15
 
/**
16
 
 * Cache storage in PHP memory.
17
 
 * It persists only during a script run and ignores the object lifetime
18
 
 * because of that.
19
 
 *
20
 
 * @author    Gunnar Wrobel <wrobel@pardus.de>
21
 
 * @category  Horde
22
 
 * @copyright 2010-2013 Horde LLC
23
 
 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
24
 
 * @link      http://pear.horde.org/index.php?package=Cache
25
 
 * @package   Cache
26
 
 */
27
 
class Horde_Cache_Storage_Mock extends Horde_Cache_Storage_Base
28
 
{
29
 
    /**
30
 
     * The storage location for this cache.
31
 
     *
32
 
     * @var array
33
 
     */
34
 
    private $_cache = array();
35
 
 
36
 
    /**
37
 
     */
38
 
    public function __sleep()
39
 
    {
40
 
        throw new BadMethodCallException('Cannot serialize this object.');
41
 
    }
42
 
 
43
 
    /**
44
 
     */
45
 
    public function get($key, $lifetime = 0)
46
 
    {
47
 
        return isset($this->_cache[$key])
48
 
            ? $this->_cache[$key]
49
 
            : false;
50
 
    }
51
 
 
52
 
    /**
53
 
     */
54
 
    public function set($key, $data, $lifetime = 0)
55
 
    {
56
 
        $this->_cache[$key] = $data;
57
 
    }
58
 
 
59
 
    /**
60
 
     */
61
 
    public function exists($key, $lifetime = 0)
62
 
    {
63
 
        return isset($this->_cache[$key]);
64
 
    }
65
 
 
66
 
    /**
67
 
     */
68
 
    public function expire($key)
69
 
    {
70
 
        unset($this->_cache[$key]);
71
 
    }
72
 
 
73
 
    /**
74
 
     */
75
 
    public function clear()
76
 
    {
77
 
        $this->_cache = array();
78
 
    }
79
 
 
80
 
}