Chris@0
|
1 <?php
|
Chris@0
|
2 /*
|
Chris@0
|
3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
Chris@0
|
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
Chris@0
|
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
Chris@0
|
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
Chris@0
|
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
Chris@0
|
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
Chris@0
|
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
Chris@0
|
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
Chris@0
|
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
Chris@0
|
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
Chris@0
|
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Chris@0
|
14 *
|
Chris@0
|
15 * This software consists of voluntary contributions made by many individuals
|
Chris@0
|
16 * and is licensed under the MIT license. For more information, see
|
Chris@0
|
17 * <http://www.doctrine-project.org>.
|
Chris@0
|
18 */
|
Chris@0
|
19
|
Chris@0
|
20 namespace Doctrine\Common\Cache;
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Interface for cache drivers.
|
Chris@0
|
24 *
|
Chris@0
|
25 * @link www.doctrine-project.org
|
Chris@0
|
26 * @since 2.0
|
Chris@0
|
27 * @author Benjamin Eberlei <kontakt@beberlei.de>
|
Chris@0
|
28 * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
Chris@0
|
29 * @author Jonathan Wage <jonwage@gmail.com>
|
Chris@0
|
30 * @author Roman Borschel <roman@code-factory.org>
|
Chris@0
|
31 * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
Chris@0
|
32 * @author Kévin Dunglas <dunglas@gmail.com>
|
Chris@0
|
33 */
|
Chris@0
|
34 interface Cache
|
Chris@0
|
35 {
|
Chris@0
|
36 const STATS_HITS = 'hits';
|
Chris@0
|
37 const STATS_MISSES = 'misses';
|
Chris@0
|
38 const STATS_UPTIME = 'uptime';
|
Chris@0
|
39 const STATS_MEMORY_USAGE = 'memory_usage';
|
Chris@0
|
40 const STATS_MEMORY_AVAILABLE = 'memory_available';
|
Chris@0
|
41 /**
|
Chris@0
|
42 * Only for backward compatibility (may be removed in next major release)
|
Chris@0
|
43 *
|
Chris@0
|
44 * @deprecated
|
Chris@0
|
45 */
|
Chris@0
|
46 const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Fetches an entry from the cache.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @param string $id The id of the cache entry to fetch.
|
Chris@0
|
52 *
|
Chris@0
|
53 * @return mixed The cached data or FALSE, if no cache entry exists for the given id.
|
Chris@0
|
54 */
|
Chris@0
|
55 public function fetch($id);
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@0
|
58 * Tests if an entry exists in the cache.
|
Chris@0
|
59 *
|
Chris@0
|
60 * @param string $id The cache id of the entry to check for.
|
Chris@0
|
61 *
|
Chris@0
|
62 * @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
Chris@0
|
63 */
|
Chris@0
|
64 public function contains($id);
|
Chris@0
|
65
|
Chris@0
|
66 /**
|
Chris@0
|
67 * Puts data into the cache.
|
Chris@0
|
68 *
|
Chris@0
|
69 * If a cache entry with the given id already exists, its data will be replaced.
|
Chris@0
|
70 *
|
Chris@0
|
71 * @param string $id The cache id.
|
Chris@0
|
72 * @param mixed $data The cache entry/data.
|
Chris@0
|
73 * @param int $lifeTime The lifetime in number of seconds for this cache entry.
|
Chris@0
|
74 * If zero (the default), the entry never expires (although it may be deleted from the cache
|
Chris@0
|
75 * to make place for other entries).
|
Chris@0
|
76 *
|
Chris@0
|
77 * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
Chris@0
|
78 */
|
Chris@0
|
79 public function save($id, $data, $lifeTime = 0);
|
Chris@0
|
80
|
Chris@0
|
81 /**
|
Chris@0
|
82 * Deletes a cache entry.
|
Chris@0
|
83 *
|
Chris@0
|
84 * @param string $id The cache id.
|
Chris@0
|
85 *
|
Chris@0
|
86 * @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
Chris@0
|
87 * Deleting a non-existing entry is considered successful.
|
Chris@0
|
88 */
|
Chris@0
|
89 public function delete($id);
|
Chris@0
|
90
|
Chris@0
|
91 /**
|
Chris@0
|
92 * Retrieves cached information from the data store.
|
Chris@0
|
93 *
|
Chris@0
|
94 * The server's statistics array has the following values:
|
Chris@0
|
95 *
|
Chris@0
|
96 * - <b>hits</b>
|
Chris@0
|
97 * Number of keys that have been requested and found present.
|
Chris@0
|
98 *
|
Chris@0
|
99 * - <b>misses</b>
|
Chris@0
|
100 * Number of items that have been requested and not found.
|
Chris@0
|
101 *
|
Chris@0
|
102 * - <b>uptime</b>
|
Chris@0
|
103 * Time that the server is running.
|
Chris@0
|
104 *
|
Chris@0
|
105 * - <b>memory_usage</b>
|
Chris@0
|
106 * Memory used by this server to store items.
|
Chris@0
|
107 *
|
Chris@0
|
108 * - <b>memory_available</b>
|
Chris@0
|
109 * Memory allowed to use for storage.
|
Chris@0
|
110 *
|
Chris@0
|
111 * @since 2.2
|
Chris@0
|
112 *
|
Chris@0
|
113 * @return array|null An associative array with server's statistics if available, NULL otherwise.
|
Chris@0
|
114 */
|
Chris@0
|
115 public function getStats();
|
Chris@0
|
116 }
|