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
75 public function set($entryIdentifier, $data, $tags = array());
78 * Finds and returns data from the cache.
80 * @param string Something which identifies the cache entry - depends on concrete cache
83 public function get($entryIdentifier);
86 * Finds and returns all cache entries which are tagged by the specified tag.
88 * @param string The tag to search for
89 * @return array An array with the content of all matching entries. An empty array if no entries matched
91 public function getByTag($tag);
94 * Checks if a cache entry with the specified identifier exists.
96 * @param string An identifier specifying the cache entry
97 * @return boolean TRUE if such an entry exists, FALSE if not
99 public function has($entryIdentifier);
102 * Removes the given cache entry from the cache.
104 * @param string An identifier specifying the cache entry
105 * @return boolean TRUE if such an entry exists, FALSE if not
107 public function remove($entryIdentifier);
110 * Removes all cache entries of this cache.
117 * Removes all cache entries of this cache which are tagged by the specified tag.
119 * @param string The tag the entries must have
122 public function flushByTag($tag);
125 * Removes all cache entries of this cache which are tagged by the specified tag.
127 * @param array Array of tags to search for and to remove the cache entries, the "*" wildcard is supported
129 * @author Ingo Renner <ingo@typo3.org>
131 public function flushByTags(array $tags);
134 * Does garbage collection
138 public function collectGarbage();
141 * Checks the validity of an entry identifier. Returns true if it's valid.
143 * @param string An identifier to be checked for validity
146 public function isValidEntryIdentifier($identifier);
149 * Checks the validity of a tag. Returns true if it's valid.
151 * @param string A tag to be checked for validity
154 public function isValidTag($tag);