TYPO3 API  SVNRelease
interface.t3lib_cache_backend_backend.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 
00028 
00029 /**
00030  * interface for a Cache Backend
00031  *
00032  * @author  Ingo Renner <ingo@typo3.org>
00033  * @package TYPO3
00034  * @api
00035  * @subpackage t3lib
00036  */
00037 interface t3lib_cache_backend_Backend {
00038 
00039     /**
00040      * Sets a reference to the cache frontend which uses this backend
00041      *
00042      * @param t3lib_cache_frontend_Frontend $cache The frontend for this backend
00043      * @return void
00044      */
00045     public function setCache(t3lib_cache_frontend_Frontend $cache);
00046 
00047     /**
00048      * Saves data in the cache.
00049      *
00050      * @param string An identifier for this specific cache entry
00051      * @param string The data to be stored
00052      * @param array Tags to associate with this cache entry
00053      * @param integer Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited liftime.
00054      * @return void
00055      * @throws t3lib_cache_Exception if no cache frontend has been set.
00056      * @throws InvalidArgumentException if the identifier is not valid
00057      * @throws t3lib_cache_Exception_InvalidData if the data is not a string
00058      */
00059     public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL);
00060 
00061     /**
00062      * Loads data from the cache.
00063      *
00064      * @param string $entryIdentifier An identifier which describes the cache entry to load
00065      * @return mixed The cache entry's content as a string or FALSE if the cache entry could not be loaded
00066      */
00067     public function get($entryIdentifier);
00068 
00069     /**
00070      * Checks if a cache entry with the specified identifier exists.
00071      *
00072      * @param string $entryIdentifier: An identifier specifying the cache entry
00073      * @return boolean TRUE if such an entry exists, FALSE if not
00074      */
00075     public function has($entryIdentifier);
00076 
00077     /**
00078      * Removes all cache entries matching the specified identifier.
00079      * Usually this only affects one entry but if - for what reason ever -
00080      * old entries for the identifier still exist, they are removed as well.
00081      *
00082      * @param string $entryIdentifier: Specifies the cache entry to remove
00083      * @return boolean TRUE if (at least) an entry could be removed or FALSE if no entry was found
00084      */
00085     public function remove($entryIdentifier);
00086 
00087     /**
00088      * Removes all cache entries of this cache.
00089      *
00090      * @return void
00091      */
00092     public function flush();
00093 
00094     /**
00095      * Removes all cache entries of this cache which are tagged by the specified tag.
00096      *
00097      * @param string $tag The tag the entries must have
00098      * @return void
00099      */
00100     public function flushByTag($tag);
00101 
00102     /**
00103      * Removes all cache entries of this cache which are tagged by the specified tags.
00104      *
00105      * @param   array   The tags the entries must have
00106      * @return void
00107      * @author  Ingo Renner <ingo@typo3.org>
00108      */
00109     public function flushByTags(array $tags);
00110 
00111     /**
00112      * Finds and returns all cache entry identifiers which are tagged by the
00113      * specified tag.
00114      *
00115      * @param string $tag The tag to search for
00116      * @return array An array with identifiers of all matching entries. An empty array if no entries matched
00117      */
00118     public function findIdentifiersByTag($tag);
00119 
00120     /**
00121      * Finds and returns all cache entry identifiers which are tagged by the
00122      * specified tags.
00123      * The asterisk ("*") is allowed as a wildcard at the beginning and the end
00124      * of a tag.
00125      *
00126      * @param array Array of tags to search for, the "*" wildcard is supported
00127      * @return array An array with identifiers of all matching entries. An empty array if no entries matched
00128      * @author  Ingo Renner <ingo@typo3.org>
00129      */
00130     public function findIdentifiersByTags(array $tags);
00131 
00132     /**
00133      * Does garbage collection
00134      *
00135      * @return void
00136      */
00137     public function collectGarbage();
00138 
00139 }
00140 
00141 
00142 ?>