mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +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
41
classes/cache/CacheApc.class.php
vendored
41
classes/cache/CacheApc.class.php
vendored
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Cache class for APC
|
||||
*
|
||||
* @author NHN (developer@xpressengine.com)
|
||||
**/
|
||||
* */
|
||||
class CacheApc extends CacheBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -18,7 +20,7 @@ class CacheApc extends CacheBase
|
|||
* @param void $opt Not used
|
||||
* @return CacheApc instance of CacheApc
|
||||
*/
|
||||
function getInstance($opt=null)
|
||||
function getInstance($opt = null)
|
||||
{
|
||||
if(!$GLOBALS['__CacheApc__'])
|
||||
{
|
||||
|
|
@ -34,6 +36,7 @@ class CacheApc extends CacheBase
|
|||
*/
|
||||
function CacheApc()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -52,14 +55,18 @@ class CacheApc extends CacheBase
|
|||
* @param string $key Store the variable using this name. $key are cache-unique, so storing a second value with the same $key will overwrite the original value.
|
||||
* @param mixed $buff The variable to store
|
||||
* @param int $valid_time Time To Live; store $buff in the cache for ttl seconds.
|
||||
* After the ttl has passed., the stored variable will be expunged from the cache (on the next request).
|
||||
* If no ttl is supplied, use the default valid time CacheApc::valid_time.
|
||||
* After the ttl has passed., the stored variable will be expunged from the cache (on the next request).
|
||||
* If no ttl is supplied, use the default valid time CacheApc::valid_time.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function put($key, $buff, $valid_time = 0)
|
||||
{
|
||||
if($valid_time == 0) $valid_time = $this->valid_time;
|
||||
return apc_store(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
|
||||
if($valid_time == 0)
|
||||
{
|
||||
$valid_time = $this->valid_time;
|
||||
}
|
||||
|
||||
return apc_store(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,14 +74,17 @@ class CacheApc extends CacheBase
|
|||
*
|
||||
* @param string $key Cache key
|
||||
* @param int $modified_time Unix time of data modified.
|
||||
* If stored time is older then modified time, the data is invalid.
|
||||
* If stored time is older then modified time, the data is invalid.
|
||||
* @return bool Return true on valid or false on invalid.
|
||||
*/
|
||||
function isValid($key, $modified_time = 0)
|
||||
{
|
||||
$_key = md5(_XE_PATH_.$key);
|
||||
$_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])
|
||||
|
|
@ -91,14 +101,17 @@ class CacheApc extends CacheBase
|
|||
*
|
||||
* @param string $key The $key used to store the value.
|
||||
* @param int $modified_time Unix time of data modified.
|
||||
* If stored time is older then modified time, return false.
|
||||
* If stored time is older then modified time, return false.
|
||||
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
|
||||
*/
|
||||
function get($key, $modified_time = 0)
|
||||
{
|
||||
$_key = md5(_XE_PATH_.$key);
|
||||
$_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])
|
||||
{
|
||||
|
|
@ -117,7 +130,7 @@ class CacheApc extends CacheBase
|
|||
*/
|
||||
function _delete($_key)
|
||||
{
|
||||
$this->put($_key,null,1);
|
||||
$this->put($_key, null, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue