gyro/core/controller/base/cachemanager/constantcachemanager.cls.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Cache manager that returns a constant value as cache id 00004 * 00005 * @author Gerd Riesselmann 00006 * @ingroup Controller 00007 */ 00008 class ConstantCacheManager implements ICacheManager { 00009 private $cache_id; 00010 00011 /** 00012 * Expiration date and time 00013 * 00014 * @var timestamp 00015 */ 00016 private $expiration; 00017 00018 /** 00019 * Creation date and time 00020 * 00021 * @var timestamp 00022 */ 00023 private $creation; 00024 00025 /** 00026 * Cache header manager 00027 * 00028 * @var ICacheHeaderManager 00029 */ 00030 private $header_manager; 00031 00032 00033 /** 00034 * Constructor 00035 * 00036 * @param mixed $cache_id 00037 * @param int $duration Cache duration , defaults to 2 hours 00038 * @param ICacheHeaderManager $header_manager Defaults to NoCacheCacheHeaderManager 00039 */ 00040 public function __construct($cache_id, $duration = 7200, $header_manager = false) { 00041 $this->set_cache_id($cache_id); 00042 $this->set_cache_duration($duration); 00043 $this->set_creation_datetime(time()); 00044 if (empty($header_manager)) { $header_manager = CacheHeaderManagerFactory::create(Config::get_value(Config::CACHEHEADER_CLASS_UNCACHED)); } 00045 $this->set_cache_header_manager($header_manager); 00046 } 00047 00048 public function initialize($page_data) { 00049 // Do nothing here 00050 } 00051 00052 /** 00053 * Return a chache id 00054 */ 00055 public function get_cache_id() { 00056 return $this->cache_id; 00057 } 00058 00059 /** 00060 * Sets the cache id 00061 * 00062 * @param mixed $id 00063 */ 00064 public function set_cache_id($id) { 00065 $this->cache_id = $id; 00066 } 00067 00068 /** 00069 * Returns the datetime this cache expires 00070 * 00071 * @return timestamp 00072 */ 00073 public function get_expiration_datetime() { 00074 return $this->expiration; 00075 } 00076 00077 /** 00078 * Sets the expiration datetime this cache expires 00079 * 00080 * @param timestamp $datetime 00081 */ 00082 public function set_expiration_datetime($datetime) { 00083 $this->expiration = $datetime; 00084 } 00085 00086 /** 00087 * Returns the datetime this cache has been created 00088 * 00089 * @return timestamp 00090 */ 00091 public function get_creation_datetime() { 00092 return $this->creation; 00093 } 00094 00095 /** 00096 * Sets the datetime this cache has been created 00097 * 00098 * @param timestamp $datetime 00099 */ 00100 public function set_creation_datetime($datetime) { 00101 $this->creation = $datetime; 00102 } 00103 00104 /** 00105 * Set Cache duration in seconds 00106 * 00107 * @param int $seconds 00108 */ 00109 public function set_cache_duration($seconds) { 00110 $this->expiration = time() + $seconds; 00111 } 00112 00113 /** 00114 * Set cache header manager 00115 */ 00116 public function set_cache_header_manager(ICacheHeaderManager $manager) { 00117 $this->header_manager = $manager; 00118 } 00119 00120 /** 00121 * Get cache header manager 00122 * 00123 * @return ICacheHeaderManager 00124 */ 00125 public function get_cache_header_manager() { 00126 return $this->header_manager; 00127 } 00128 }