| [ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 /** 12 * sfCache is an abstract class for all cache classes in symfony. 13 * 14 * @package symfony 15 * @subpackage cache 16 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 17 * @author Fabien Marty <fab@php.net> 18 * @version SVN: $Id: sfCache.class.php 3198 2007-01-08 20:36:20Z fabien $ 19 */ 20 abstract class sfCache 21 { 22 /** 23 * Cache lifetime (in seconds) 24 * 25 * @var int $lifeTime 26 */ 27 protected $lifeTime = 86400; 28 29 /** 30 * Timestamp of the last valid cache 31 * 32 * @var int $refreshTime 33 */ 34 protected $refreshTime; 35 36 /** 37 * Gets the cache content for a given id and namespace. 38 * 39 * @param string The cache id 40 * @param string The name of the cache namespace 41 * @param boolean If set to true, the cache validity won't be tested 42 * 43 * @return string The data of the cache (or null if no cache available) 44 */ 45 abstract public function get($id, $namespace = self::DEFAULT_NAMESPACE, $doNotTestCacheValidity = false); 46 47 /** 48 * Returns true if there is a cache for the given id and namespace. 49 * 50 * @param string The cache id 51 * @param string The name of the cache namespace 52 * @param boolean If set to true, the cache validity won't be tested 53 * 54 * @return boolean true if the cache exists, false otherwise 55 */ 56 abstract public function has($id, $namespace = self::DEFAULT_NAMESPACE, $doNotTestCacheValidity = false); 57 58 /** 59 * Saves some data in the cache. 60 * 61 * @param string The cache id 62 * @param string The name of the cache namespace 63 * @param string The data to put in cache 64 * 65 * @return boolean true if no problem 66 */ 67 abstract public function set($id, $namespace = self::DEFAULT_NAMESPACE, $data); 68 69 /** 70 * Removes a content from the cache. 71 * 72 * @param string The cache id 73 * @param string The name of the cache namespace 74 * 75 * @return boolean true if no problem 76 */ 77 abstract public function remove($id, $namespace = self::DEFAULT_NAMESPACE); 78 79 /** 80 * Cleans the cache. 81 * 82 * If no namespace is specified all cache content will be destroyed 83 * else only cache contents of the specified namespace will be destroyed. 84 * 85 * @param string The name of the cache namespace 86 * 87 * @return boolean true if no problem 88 */ 89 abstract public function clean($namespace = null, $mode = 'all'); 90 91 /** 92 * Sets a new life time. 93 * 94 * @param int The new life time (in seconds) 95 */ 96 public function setLifeTime($newLifeTime) 97 { 98 $this->lifeTime = $newLifeTime; 99 $this->refreshTime = time() - $newLifeTime; 100 } 101 102 /** 103 * Returns the current life time. 104 * 105 * @return int The current life time (in seconds) 106 */ 107 public function getLifeTime() 108 { 109 return $this->lifeTime; 110 } 111 112 /** 113 * Returns the cache last modification time. 114 * 115 * @return int The last modification time 116 */ 117 abstract public function lastModified($id, $namespace = self::DEFAULT_NAMESPACE); 118 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |