Chris@0: . Chris@0: */ Chris@0: Chris@0: namespace Doctrine\Common\Cache; Chris@0: Chris@0: /** Chris@0: * Interface for cache drivers. Chris@0: * Chris@0: * @link www.doctrine-project.org Chris@0: * @since 2.0 Chris@0: * @author Benjamin Eberlei Chris@0: * @author Guilherme Blanco Chris@0: * @author Jonathan Wage Chris@0: * @author Roman Borschel Chris@0: * @author Fabio B. Silva Chris@0: * @author Kévin Dunglas Chris@0: */ Chris@0: interface Cache Chris@0: { Chris@0: const STATS_HITS = 'hits'; Chris@0: const STATS_MISSES = 'misses'; Chris@0: const STATS_UPTIME = 'uptime'; Chris@0: const STATS_MEMORY_USAGE = 'memory_usage'; Chris@0: const STATS_MEMORY_AVAILABLE = 'memory_available'; Chris@0: /** Chris@0: * Only for backward compatibility (may be removed in next major release) Chris@0: * Chris@0: * @deprecated Chris@0: */ Chris@0: const STATS_MEMORY_AVAILIABLE = 'memory_available'; Chris@0: Chris@0: /** Chris@0: * Fetches an entry from the cache. Chris@0: * Chris@0: * @param string $id The id of the cache entry to fetch. Chris@0: * Chris@0: * @return mixed The cached data or FALSE, if no cache entry exists for the given id. Chris@0: */ Chris@0: public function fetch($id); Chris@0: Chris@0: /** Chris@0: * Tests if an entry exists in the cache. Chris@0: * Chris@0: * @param string $id The cache id of the entry to check for. Chris@0: * Chris@0: * @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise. Chris@0: */ Chris@0: public function contains($id); Chris@0: Chris@0: /** Chris@0: * Puts data into the cache. Chris@0: * Chris@0: * If a cache entry with the given id already exists, its data will be replaced. Chris@0: * Chris@0: * @param string $id The cache id. Chris@0: * @param mixed $data The cache entry/data. Chris@0: * @param int $lifeTime The lifetime in number of seconds for this cache entry. Chris@0: * If zero (the default), the entry never expires (although it may be deleted from the cache Chris@0: * to make place for other entries). Chris@0: * Chris@0: * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise. Chris@0: */ Chris@0: public function save($id, $data, $lifeTime = 0); Chris@0: Chris@0: /** Chris@0: * Deletes a cache entry. Chris@0: * Chris@0: * @param string $id The cache id. Chris@0: * Chris@0: * @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise. Chris@0: * Deleting a non-existing entry is considered successful. Chris@0: */ Chris@0: public function delete($id); Chris@0: Chris@0: /** Chris@0: * Retrieves cached information from the data store. Chris@0: * Chris@0: * The server's statistics array has the following values: Chris@0: * Chris@0: * - hits Chris@0: * Number of keys that have been requested and found present. Chris@0: * Chris@0: * - misses Chris@0: * Number of items that have been requested and not found. Chris@0: * Chris@0: * - uptime Chris@0: * Time that the server is running. Chris@0: * Chris@0: * - memory_usage Chris@0: * Memory used by this server to store items. Chris@0: * Chris@0: * - memory_available Chris@0: * Memory allowed to use for storage. Chris@0: * Chris@0: * @since 2.2 Chris@0: * Chris@0: * @return array|null An associative array with server's statistics if available, NULL otherwise. Chris@0: */ Chris@0: public function getStats(); Chris@0: }