mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 17:44:38 +09:00
issue 2119. supporting php 5.4.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12684 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
854e45afaa
commit
bd1fa3651d
5 changed files with 173 additions and 75 deletions
21
classes/cache/CacheApc.class.php
vendored
21
classes/cache/CacheApc.class.php
vendored
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Cache class for APC
|
||||
*
|
||||
|
|
@ -6,6 +7,7 @@
|
|||
* */
|
||||
class CacheApc extends CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -34,6 +36,7 @@ class CacheApc extends CacheBase
|
|||
*/
|
||||
function CacheApc()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +61,11 @@ class CacheApc extends CacheBase
|
|||
*/
|
||||
function put($key, $buff, $valid_time = 0)
|
||||
{
|
||||
if($valid_time == 0) $valid_time = $this->valid_time;
|
||||
if($valid_time == 0)
|
||||
{
|
||||
$valid_time = $this->valid_time;
|
||||
}
|
||||
|
||||
return apc_store(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +81,10 @@ class CacheApc extends CacheBase
|
|||
{
|
||||
$_key = md5(_XE_PATH_ . $key);
|
||||
$obj = apc_fetch($_key, $success);
|
||||
if(!$success || !is_array($obj)) return false;
|
||||
if(!$success || !is_array($obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
unset($obj[1]);
|
||||
|
||||
if($modified_time > 0 && $modified_time > $obj[0])
|
||||
|
|
@ -98,7 +108,10 @@ class CacheApc extends CacheBase
|
|||
{
|
||||
$_key = md5(_XE_PATH_ . $key);
|
||||
$obj = apc_fetch($_key, $success);
|
||||
if(!$success || !is_array($obj)) return false;
|
||||
if(!$success || !is_array($obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($modified_time > 0 && $modified_time > $obj[0])
|
||||
{
|
||||
|
|
@ -140,7 +153,7 @@ class CacheApc extends CacheBase
|
|||
{
|
||||
return apc_clear_cache('user');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file CacheApc.class.php */
|
||||
/* Location: ./classes/cache/CacheApc.class.php */
|
||||
|
|
|
|||
22
classes/cache/CacheFile.class.php
vendored
22
classes/cache/CacheFile.class.php
vendored
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Cache class for file
|
||||
*
|
||||
|
|
@ -8,6 +9,7 @@
|
|||
*/
|
||||
class CacheFile extends CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -27,7 +29,8 @@ class CacheFile extends CacheBase
|
|||
*/
|
||||
function getInstance()
|
||||
{
|
||||
if(!$GLOBALS['__CacheFile__']) {
|
||||
if(!$GLOBALS['__CacheFile__'])
|
||||
{
|
||||
$GLOBALS['__CacheFile__'] = new CacheFile();
|
||||
}
|
||||
return $GLOBALS['__CacheFile__'];
|
||||
|
|
@ -41,7 +44,10 @@ class CacheFile extends CacheBase
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,7 +96,10 @@ class CacheFile extends CacheBase
|
|||
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;
|
||||
}
|
||||
|
|
@ -106,7 +115,10 @@ class CacheFile extends CacheBase
|
|||
{
|
||||
$cache_file = $this->getCacheFileName($key);
|
||||
$content = FileHandler::readFile($cache_file);
|
||||
if(!$content) return false;
|
||||
if(!$content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($content);
|
||||
}
|
||||
|
|
@ -143,7 +155,7 @@ class CacheFile extends CacheBase
|
|||
{
|
||||
FileHandler::removeFilesInDir($this->cache_dir);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file CacheFile.class.php */
|
||||
/* Location: ./classes/cache/CacheFile.class.php */
|
||||
|
|
|
|||
72
classes/cache/CacheHandler.class.php
vendored
72
classes/cache/CacheHandler.class.php
vendored
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* CacheHandler
|
||||
*
|
||||
|
|
@ -6,6 +7,7 @@
|
|||
*/
|
||||
class CacheHandler extends Handler
|
||||
{
|
||||
|
||||
/**
|
||||
* instance of cache handler
|
||||
* @var CacheBase
|
||||
|
|
@ -49,30 +51,52 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function CacheHandler($target, $info = null, $always_use_file = false)
|
||||
{
|
||||
if(!$info) $info = Context::getDBInfo();
|
||||
if(!$info)
|
||||
{
|
||||
$info = Context::getDBInfo();
|
||||
}
|
||||
|
||||
if($info)
|
||||
{
|
||||
if($target == 'object')
|
||||
{
|
||||
if($info->use_object_cache =='apc') $type = 'apc';
|
||||
if($info->use_object_cache == 'apc')
|
||||
{
|
||||
$type = 'apc';
|
||||
}
|
||||
else if(substr($info->use_object_cache, 0, 8) == 'memcache')
|
||||
{
|
||||
$type = 'memcache';
|
||||
$url = $info->use_object_cache;
|
||||
}
|
||||
else if($info->use_object_cache == 'wincache') $type = 'wincache';
|
||||
else if($info->use_object_cache =='file') $type = 'file';
|
||||
else if($always_use_file) $type = 'file';
|
||||
else if($info->use_object_cache == 'wincache')
|
||||
{
|
||||
$type = 'wincache';
|
||||
}
|
||||
else if($info->use_object_cache == 'file')
|
||||
{
|
||||
$type = 'file';
|
||||
}
|
||||
else if($always_use_file)
|
||||
{
|
||||
$type = 'file';
|
||||
}
|
||||
}
|
||||
else if($target == 'template')
|
||||
{
|
||||
if($info->use_template_cache =='apc') $type = 'apc';
|
||||
if($info->use_template_cache == 'apc')
|
||||
{
|
||||
$type = 'apc';
|
||||
}
|
||||
else if(substr($info->use_template_cache, 0, 8) == 'memcache')
|
||||
{
|
||||
$type = 'memcache';
|
||||
$url = $info->use_template_cache;
|
||||
}
|
||||
else if($info->use_template_cache == 'wincache') $type = 'wincache';
|
||||
else if($info->use_template_cache == 'wincache')
|
||||
{
|
||||
$type = 'wincache';
|
||||
}
|
||||
}
|
||||
|
||||
if($type)
|
||||
|
|
@ -97,7 +121,10 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function isSupport()
|
||||
{
|
||||
if($this->handler && $this->handler->isSupport()) return true;
|
||||
if($this->handler && $this->handler->isSupport())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +138,10 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function get($key, $modified_time = 0)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
if(!$this->handler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $this->handler->get($key, $modified_time);
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +157,10 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function put($key, $obj, $valid_time = 0)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
if(!$this->handler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $this->handler->put($key, $obj, $valid_time);
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +172,10 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function delete($key)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
if(!$this->handler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $this->handler->delete($key);
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +189,10 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function isValid($key, $modified_time)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
if(!$this->handler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $this->handler->isValid($key, $modified_time);
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +203,10 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
function truncate()
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
if(!$this->handler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $this->handler->truncate();
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +248,7 @@ class CacheHandler extends Handler
|
|||
$this->keyGroupVersions[$keyGroupName]++;
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,6 +258,7 @@ class CacheHandler extends Handler
|
|||
*/
|
||||
class CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Get cached data
|
||||
*
|
||||
|
|
@ -275,7 +319,7 @@ class CacheBase
|
|||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file CacheHandler.class.php */
|
||||
/* Location: ./classes/cache/CacheHandler.class.php */
|
||||
|
|
|
|||
27
classes/cache/CacheMemcache.class.php
vendored
27
classes/cache/CacheMemcache.class.php
vendored
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Cache class for memcache
|
||||
*
|
||||
|
|
@ -6,6 +7,7 @@
|
|||
*/
|
||||
class CacheMemcache extends CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -26,7 +28,8 @@ class CacheMemcache extends CacheBase
|
|||
*/
|
||||
function getInstance($url)
|
||||
{
|
||||
if(!$GLOBALS['__CacheMemcache__']) {
|
||||
if(!$GLOBALS['__CacheMemcache__'])
|
||||
{
|
||||
$GLOBALS['__CacheMemcache__'] = new CacheMemcache($url);
|
||||
}
|
||||
return $GLOBALS['__CacheMemcache__'];
|
||||
|
|
@ -59,7 +62,10 @@ class CacheMemcache extends CacheBase
|
|||
*/
|
||||
function isSupport()
|
||||
{
|
||||
if($GLOBALS['XE_MEMCACHE_SUPPORT']) return true;
|
||||
if($GLOBALS['XE_MEMCACHE_SUPPORT'])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1))
|
||||
{
|
||||
$GLOBALS['XE_MEMCACHE_SUPPORT'] = true;
|
||||
|
|
@ -101,7 +107,10 @@ class CacheMemcache extends CacheBase
|
|||
*/
|
||||
function put($key, $buff, $valid_time = 0)
|
||||
{
|
||||
if($valid_time == 0) $valid_time = $this->valid_time;
|
||||
if($valid_time == 0)
|
||||
{
|
||||
$valid_time = $this->valid_time;
|
||||
}
|
||||
|
||||
return $this->Memcache->set($this->getKey($key), array(time(), $buff), MEMCACHE_COMPRESSED, $valid_time);
|
||||
}
|
||||
|
|
@ -119,7 +128,10 @@ class CacheMemcache extends CacheBase
|
|||
$_key = $this->getKey($key);
|
||||
|
||||
$obj = $this->Memcache->get($_key);
|
||||
if(!$obj || !is_array($obj)) return false;
|
||||
if(!$obj || !is_array($obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
unset($obj[1]);
|
||||
|
||||
if($modified_time > 0 && $modified_time > $obj[0])
|
||||
|
|
@ -145,7 +157,10 @@ class CacheMemcache extends CacheBase
|
|||
{
|
||||
$_key = $this->getKey($key);
|
||||
$obj = $this->Memcache->get($_key);
|
||||
if(!$obj || !is_array($obj)) return false;
|
||||
if(!$obj || !is_array($obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($modified_time > 0 && $modified_time > $obj[0])
|
||||
{
|
||||
|
|
@ -197,7 +212,7 @@ class CacheMemcache extends CacheBase
|
|||
{
|
||||
return $this->Memcache->flush();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file CacheMemcache.class.php */
|
||||
/* Location: ./classes/cache/CacheMemcache.class.php */
|
||||
|
|
|
|||
26
classes/cache/CacheWincache.class.php
vendored
26
classes/cache/CacheWincache.class.php
vendored
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Cache class for Wincache
|
||||
*
|
||||
|
|
@ -6,7 +7,9 @@
|
|||
*
|
||||
* @author Arnia (support@xpressengine.org)
|
||||
*/
|
||||
class CacheWincache extends CacheBase {
|
||||
class CacheWincache extends CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -21,7 +24,8 @@ class CacheWincache extends CacheBase {
|
|||
*/
|
||||
function getInstance($opt = null)
|
||||
{
|
||||
if(!$GLOBALS['__CacheWincache__']) {
|
||||
if(!$GLOBALS['__CacheWincache__'])
|
||||
{
|
||||
$GLOBALS['__CacheWincache__'] = new CacheWincache();
|
||||
}
|
||||
return $GLOBALS['__CacheWincache__'];
|
||||
|
|
@ -34,6 +38,7 @@ class CacheWincache extends CacheBase {
|
|||
*/
|
||||
function CacheWincache()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +64,10 @@ class CacheWincache extends CacheBase {
|
|||
*/
|
||||
function put($key, $buff, $valid_time = 0)
|
||||
{
|
||||
if($valid_time == 0) $valid_time = $this->valid_time;
|
||||
if($valid_time == 0)
|
||||
{
|
||||
$valid_time = $this->valid_time;
|
||||
}
|
||||
return wincache_ucache_set(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +83,10 @@ class CacheWincache extends CacheBase {
|
|||
{
|
||||
$_key = md5(_XE_PATH_ . $key);
|
||||
$obj = wincache_ucache_get($_key, $success);
|
||||
if(!$success || !is_array($obj)) return false;
|
||||
if(!$success || !is_array($obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
unset($obj[1]);
|
||||
|
||||
if($modified_time > 0 && $modified_time > $obj[0])
|
||||
|
|
@ -99,7 +110,10 @@ class CacheWincache extends CacheBase {
|
|||
{
|
||||
$_key = md5(_XE_PATH_ . $key);
|
||||
$obj = wincache_ucache_get($_key, $success);
|
||||
if(!$success || !is_array($obj)) return false;
|
||||
if(!$success || !is_array($obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($modified_time > 0 && $modified_time > $obj[0])
|
||||
{
|
||||
|
|
@ -142,7 +156,7 @@ class CacheWincache extends CacheBase {
|
|||
{
|
||||
return wincache_ucache_clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file CacheWincache.class.php */
|
||||
/* Location: ./classes/cache/CacheWincache.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue