2 /***************************************************************
5 * (c) 2009 Ingo Renner <ingo@typo3.org>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
30 * interface for a Cache Frontend
32 * @author Ingo Renner <ingo@typo3.org>
34 * @subpackage t3lib_cache
36 interface t3lib_cache_frontend_Frontend
{
39 * "Magic" tag for class-related entries
41 const TAG_CLASS
= '%CLASS%';
44 * Pattern an entry identifer must match.
46 const PATTERN_ENTRYIDENTIFIER
= '/^[a-zA-Z0-9_%\-&]{1,250}$/';
49 * Pattern a tag must match.
51 const PATTERN_TAG
= '/^[a-zA-Z0-9_%\-&]{1,250}$/';
54 * Returns this cache's identifier
56 * @return string The identifier for this cache
58 public function getIdentifier();
61 * Returns the backend used by this cache
63 * @return t3lib_cache_backend_Backend The backend used by this cache
65 public function getBackend();
68 * Saves data in the cache.
70 * @param string Something which identifies the data - depends on concrete cache
71 * @param mixed The data to cache - also depends on the concrete cache implementation
72 * @param array Tags to associate with this cache entry
73 * @param integer Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited liftime.
76 public function set($entryIdentifier, $data, $tags = array(), $lifetime = NULL);
79 * Finds and returns data from the cache.
81 * @param string Something which identifies the cache entry - depends on concrete cache
84 public function get($entryIdentifier);
87 * Finds and returns all cache entries which are tagged by the specified tag.
89 * @param string The tag to search for
90 * @return array An array with the content of all matching entries. An empty array if no entries matched
92 public function getByTag($tag);
95 * Checks if a cache entry with the specified identifier exists.
97 * @param string An identifier specifying the cache entry
98 * @return boolean TRUE if such an entry exists, FALSE if not
100 public function has($entryIdentifier);
103 * Removes the given cache entry from the cache.
105 * @param string An identifier specifying the cache entry
106 * @return boolean TRUE if such an entry exists, FALSE if not
109 public function remove($entryIdentifier);
112 * Removes all cache entries of this cache.
119 * Removes all cache entries of this cache which are tagged by the specified tag.
121 * @param string The tag the entries must have
124 public function flushByTag($tag);
127 * Removes all cache entries of this cache which are tagged by the specified tag.
129 * @param array Array of tags to search for and to remove the cache entries, the "*" wildcard is supported
131 * @author Ingo Renner <ingo@typo3.org>
133 public function flushByTags(array $tags);
136 * Does garbage collection
140 public function collectGarbage();
143 * Checks the validity of an entry identifier. Returns true if it's valid.
145 * @param string An identifier to be checked for validity
148 public function isValidEntryIdentifier($identifier);
151 * Checks the validity of a tag. Returns true if it's valid.
153 * @param string A tag to be checked for validity
156 public function isValidTag($tag);