mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-15 01:09:57 +09:00
merge from 1.5.3 (~r10943)
git-svn-id: http://xe-core.googlecode.com/svn/trunk@10951 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7aa4798373
commit
54e3a72065
334 changed files with 13011 additions and 5561 deletions
77
classes/cache/CacheFile.class.php
vendored
77
classes/cache/CacheFile.class.php
vendored
|
|
@ -1,15 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* @class CacheFile
|
||||
* Cache class for file
|
||||
*
|
||||
* Filedisk Cache Handler
|
||||
*
|
||||
* @author Arnia Software (xe_dev@arnia.ro)
|
||||
* @brief Filedisk Cache Handler
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class CacheFile extends CacheBase {
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
*/
|
||||
var $valid_time = 36000;
|
||||
|
||||
/**
|
||||
* Path that value to stored
|
||||
* @var string
|
||||
*/
|
||||
var $cache_dir = 'files/cache/store/';
|
||||
|
||||
/**
|
||||
* Get instance of CacheFile
|
||||
*
|
||||
* @return CacheFile instance of CacheFile
|
||||
*/
|
||||
function getInstance(){
|
||||
if(!$GLOBALS['__CacheFile__']) {
|
||||
$GLOBALS['__CacheFile__'] = new CacheFile();
|
||||
|
|
@ -17,25 +31,56 @@ class CacheFile extends CacheBase {
|
|||
return $GLOBALS['__CacheFile__'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function CacheFile(){
|
||||
$this->cache_dir = _XE_PATH_ . $this->cache_dir;
|
||||
if(!is_dir($this->cache_dir)) FileHandler::makeDir($this->cache_dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache file name by key
|
||||
*
|
||||
* @param string $key The key that will be associated with the item.
|
||||
* @return string Returns cache file path
|
||||
*/
|
||||
function getCacheFileName($key){
|
||||
return $this->cache_dir . str_replace(':', '_', $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether support or not support cache
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
function isSupport(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache a variable in the data store
|
||||
*
|
||||
* @param string $key Store the variable using this name.
|
||||
* @param mixed $obj The variable to store
|
||||
* @param int $valid_time Not used
|
||||
* @return void
|
||||
*/
|
||||
function put($key, $obj, $valid_time = 0){
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
$text = serialize($obj);
|
||||
FileHandler::writeFile($cache_file, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether cache is valid or invalid
|
||||
*
|
||||
* @param string $key Cache key
|
||||
* @param int $modified_time Not used
|
||||
* @return bool Return true on valid or false on invalid.
|
||||
*/
|
||||
function isValid($key, $modified_time = 0) {
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
if(file_exists($cache_file)) return true;
|
||||
|
|
@ -43,6 +88,13 @@ class CacheFile extends CacheBase {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a stored variable from the cache
|
||||
*
|
||||
* @param string $key The $key used to store the value.
|
||||
* @param int $modified_time Not used
|
||||
* @return false|mixed Return false on failure. Return the string associated with the $key on success.
|
||||
*/
|
||||
function get($key, $modified_time = 0) {
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
$content = FileHandler::readFile($cache_file);
|
||||
|
|
@ -51,15 +103,32 @@ class CacheFile extends CacheBase {
|
|||
return unserialize($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variable from the cache(private)
|
||||
*
|
||||
* @param string $_key Used to store the value.
|
||||
* @return void
|
||||
*/
|
||||
function _delete($_key) {
|
||||
$cache_file = $this->getCacheFileName($_key);
|
||||
FileHandler::removeFile($cache_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variable from the cache
|
||||
*
|
||||
* @param string $key Used to store the value.
|
||||
* @return void
|
||||
*/
|
||||
function delete($key) {
|
||||
$this->_delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate all existing variables at the cache
|
||||
*
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function truncate() {
|
||||
FileHandler::removeFilesInDir($this->cache_dir);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue