mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-15 01:09:57 +09:00
merge from 1.7.3.5(r13153:r13167)
git-svn-id: http://xe-core.googlecode.com/svn/trunk@13168 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cc47d2b247
commit
2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions
67
classes/cache/CacheFile.class.php
vendored
67
classes/cache/CacheFile.class.php
vendored
|
|
@ -1,12 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Cache class for file
|
||||
*
|
||||
* Filedisk Cache Handler
|
||||
*
|
||||
* @author Arnia Software (xe_dev@arnia.ro)
|
||||
**/
|
||||
class CacheFile extends CacheBase {
|
||||
*/
|
||||
class CacheFile extends CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -18,14 +21,16 @@ class CacheFile extends CacheBase {
|
|||
* @var string
|
||||
*/
|
||||
var $cache_dir = 'files/cache/store/';
|
||||
|
||||
|
||||
/**
|
||||
* Get instance of CacheFile
|
||||
*
|
||||
* @return CacheFile instance of CacheFile
|
||||
*/
|
||||
function getInstance(){
|
||||
if(!$GLOBALS['__CacheFile__']) {
|
||||
function getInstance()
|
||||
{
|
||||
if(!$GLOBALS['__CacheFile__'])
|
||||
{
|
||||
$GLOBALS['__CacheFile__'] = new CacheFile();
|
||||
}
|
||||
return $GLOBALS['__CacheFile__'];
|
||||
|
|
@ -36,9 +41,13 @@ class CacheFile extends CacheBase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function CacheFile(){
|
||||
function CacheFile()
|
||||
{
|
||||
$this->cache_dir = _XE_PATH_ . $this->cache_dir;
|
||||
if(!is_dir($this->cache_dir)) FileHandler::makeDir($this->cache_dir);
|
||||
if(!is_dir($this->cache_dir))
|
||||
{
|
||||
FileHandler::makeDir($this->cache_dir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -47,16 +56,18 @@ class CacheFile extends CacheBase {
|
|||
* @param string $key The key that will be associated with the item.
|
||||
* @return string Returns cache file path
|
||||
*/
|
||||
function getCacheFileName($key){
|
||||
function getCacheFileName($key)
|
||||
{
|
||||
return $this->cache_dir . str_replace(':', '_', $key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return whether support or not support cache
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
function isSupport(){
|
||||
function isSupport()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -68,8 +79,9 @@ class CacheFile extends CacheBase {
|
|||
* @param int $valid_time Not used
|
||||
* @return void
|
||||
*/
|
||||
function put($key, $obj, $valid_time = 0){
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
function put($key, $obj, $valid_time = 0)
|
||||
{
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
$text = serialize($obj);
|
||||
FileHandler::writeFile($cache_file, $text);
|
||||
}
|
||||
|
|
@ -81,10 +93,14 @@ class CacheFile extends CacheBase {
|
|||
* @param int $modified_time Not used
|
||||
* @return bool Return true on valid or false on invalid.
|
||||
*/
|
||||
function isValid($key, $modified_time = 0) {
|
||||
function isValid($key, $modified_time = 0)
|
||||
{
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
if(file_exists($cache_file)) return true;
|
||||
|
||||
if(file_exists($cache_file))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -95,11 +111,15 @@ class CacheFile extends CacheBase {
|
|||
* @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) {
|
||||
function get($key, $modified_time = 0)
|
||||
{
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
$content = FileHandler::readFile($cache_file);
|
||||
if(!$content) return false;
|
||||
|
||||
if(!$content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($content);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +129,8 @@ class CacheFile extends CacheBase {
|
|||
* @param string $_key Used to store the value.
|
||||
* @return void
|
||||
*/
|
||||
function _delete($_key) {
|
||||
function _delete($_key)
|
||||
{
|
||||
$cache_file = $this->getCacheFileName($_key);
|
||||
FileHandler::removeFile($cache_file);
|
||||
}
|
||||
|
|
@ -120,7 +141,8 @@ class CacheFile extends CacheBase {
|
|||
* @param string $key Used to store the value.
|
||||
* @return void
|
||||
*/
|
||||
function delete($key) {
|
||||
function delete($key)
|
||||
{
|
||||
$this->_delete($key);
|
||||
}
|
||||
|
||||
|
|
@ -129,10 +151,11 @@ class CacheFile extends CacheBase {
|
|||
*
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function truncate() {
|
||||
function truncate()
|
||||
{
|
||||
FileHandler::removeFilesInDir($this->cache_dir);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file CacheFile.class.php */
|
||||
/* Location: ./classes/cache/CacheFile.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue