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