From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- framework/I18N/core/MessageCache.php | 342 +++++++++++++++++------------------ 1 file changed, 171 insertions(+), 171 deletions(-) (limited to 'framework/I18N/core/MessageCache.php') diff --git a/framework/I18N/core/MessageCache.php b/framework/I18N/core/MessageCache.php index d4f58f1d..44392b79 100644 --- a/framework/I18N/core/MessageCache.php +++ b/framework/I18N/core/MessageCache.php @@ -1,171 +1,171 @@ - $cacheDir, - 'lifeTime' => $this->getLifeTime(), - 'automaticSerialization' => true - ); - - $this->cache = new TCache_Lite($options); - } - - /** - * Get the cache life time. - * @return int Cache life time. - */ - public function getLifeTime() - { - return $this->lifetime; - } - - /** - * Set the cache life time. - * @param int $time Cache life time. - */ - public function setLifeTime($time) - { - $this->lifetime = (int)$time; - } - - /** - * Get the cache file ID based section and locale. - * @param string $catalogue The translation section. - * @param string $culture The translation locale, e.g. "en_AU". - */ - protected function getID($catalogue, $culture) - { - return $catalogue.':'.$culture; - } - - /** - * Get the cache file GROUP based section and locale. - * @param string $catalogue The translation section. - * @param string $culture The translation locale, e.g. "en_AU". - */ - protected function getGroup($catalogue, $culture) - { - return $catalogue.':'.get_class($this); - } - - /** - * Get the data from the cache. - * @param string $catalogue The translation section. - * @param string $culture The translation locale, e.g. "en_AU". - * @param string $filename If the source is a file, this file's modified - * time is newer than the cache's modified time, no cache hit. - * @return mixed Boolean FALSE if no cache hit. Otherwise, translation - * table data for the specified section and locale. - */ - public function get($catalogue, $culture, $lastmodified=0) - { - $ID = $this->getID($catalogue, $culture); - $group = $this->getGroup($catalogue, $culture); - - $this->cache->_setFileName($ID, $group); - - $cache = $this->cache->getCacheFile(); - - if(is_file($cache) == false) - return false; - - - $lastmodified = (int)$lastmodified; - - if($lastmodified <= 0 || $lastmodified > filemtime($cache)) - return false; - - //echo '@@ Cache hit: "'.$ID.'" : "'.$group.'"'; - //echo "
\n"; - - return $this->cache->get($ID, $group); - } - - /** - * Save the data to cache for the specified section and locale. - * @param array $data The data to save. - * @param string $catalogue The translation section. - * @param string $culture The translation locale, e.g. "en_AU". - */ - public function save($data, $catalogue, $culture) - { - $ID = $this->getID($catalogue, $culture); - $group = $this->getGroup($catalogue, $culture); - - //echo '## Cache save: "'.$ID.'" : "'.$group.'"'; - //echo "
\n"; - - return $this->cache->save($data, $ID, $group); - } - - /** - * Clean up the cache for the specified section and locale. - * @param string $catalogue The translation section. - * @param string $culture The translation locale, e.g. "en_AU". - */ - public function clean($catalogue, $culture) - { - $group = $this->getGroup($catalogue, $culture); - $this->cache->clean($group); - } - - /** - * Flush the cache. Deletes all the cache files. - */ - public function clear() - { - $this->cache->clean(); - } - -} - -?> + $cacheDir, + 'lifeTime' => $this->getLifeTime(), + 'automaticSerialization' => true + ); + + $this->cache = new TCache_Lite($options); + } + + /** + * Get the cache life time. + * @return int Cache life time. + */ + public function getLifeTime() + { + return $this->lifetime; + } + + /** + * Set the cache life time. + * @param int $time Cache life time. + */ + public function setLifeTime($time) + { + $this->lifetime = (int)$time; + } + + /** + * Get the cache file ID based section and locale. + * @param string $catalogue The translation section. + * @param string $culture The translation locale, e.g. "en_AU". + */ + protected function getID($catalogue, $culture) + { + return $catalogue.':'.$culture; + } + + /** + * Get the cache file GROUP based section and locale. + * @param string $catalogue The translation section. + * @param string $culture The translation locale, e.g. "en_AU". + */ + protected function getGroup($catalogue, $culture) + { + return $catalogue.':'.get_class($this); + } + + /** + * Get the data from the cache. + * @param string $catalogue The translation section. + * @param string $culture The translation locale, e.g. "en_AU". + * @param string $filename If the source is a file, this file's modified + * time is newer than the cache's modified time, no cache hit. + * @return mixed Boolean FALSE if no cache hit. Otherwise, translation + * table data for the specified section and locale. + */ + public function get($catalogue, $culture, $lastmodified=0) + { + $ID = $this->getID($catalogue, $culture); + $group = $this->getGroup($catalogue, $culture); + + $this->cache->_setFileName($ID, $group); + + $cache = $this->cache->getCacheFile(); + + if(is_file($cache) == false) + return false; + + + $lastmodified = (int)$lastmodified; + + if($lastmodified <= 0 || $lastmodified > filemtime($cache)) + return false; + + //echo '@@ Cache hit: "'.$ID.'" : "'.$group.'"'; + //echo "
\n"; + + return $this->cache->get($ID, $group); + } + + /** + * Save the data to cache for the specified section and locale. + * @param array $data The data to save. + * @param string $catalogue The translation section. + * @param string $culture The translation locale, e.g. "en_AU". + */ + public function save($data, $catalogue, $culture) + { + $ID = $this->getID($catalogue, $culture); + $group = $this->getGroup($catalogue, $culture); + + //echo '## Cache save: "'.$ID.'" : "'.$group.'"'; + //echo "
\n"; + + return $this->cache->save($data, $ID, $group); + } + + /** + * Clean up the cache for the specified section and locale. + * @param string $catalogue The translation section. + * @param string $culture The translation locale, e.g. "en_AU". + */ + public function clean($catalogue, $culture) + { + $group = $this->getGroup($catalogue, $culture); + $this->cache->clean($group); + } + + /** + * Flush the cache. Deletes all the cache files. + */ + public function clear() + { + $this->cache->clean(); + } + +} + +?> -- cgit v1.2.3