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:
ngleader 2013-09-29 23:32:39 +00:00
parent cc47d2b247
commit 2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions

View file

@ -1,10 +1,13 @@
<?php
/**
* Cache class for APC
*
* @author NHN (developer@xpressengine.com)
**/
class CacheApc extends CacheBase {
* */
class CacheApc extends CacheBase
{
/**
* Default valid time
* @var int
@ -17,8 +20,10 @@ class CacheApc extends CacheBase {
* @param void $opt Not used
* @return CacheApc instance of CacheApc
*/
function getInstance($opt=null){
if(!$GLOBALS['__CacheApc__']) {
function getInstance($opt = null)
{
if(!$GLOBALS['__CacheApc__'])
{
$GLOBALS['__CacheApc__'] = new CacheApc();
}
return $GLOBALS['__CacheApc__'];
@ -29,7 +34,9 @@ class CacheApc extends CacheBase {
*
* @return void
*/
function CacheApc(){
function CacheApc()
{
}
/**
@ -37,7 +44,8 @@ class CacheApc extends CacheBase {
*
* @return bool Return true on support or false on not support
*/
function isSupport(){
function isSupport()
{
return function_exists('apc_add');
}
@ -47,13 +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);
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);
}
/**
@ -61,20 +74,25 @@ 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);
function isValid($key, $modified_time = 0)
{
$_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]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
return true;
}
@ -83,15 +101,20 @@ 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);
function get($key, $modified_time = 0)
{
$_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]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
@ -105,8 +128,9 @@ class CacheApc extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
function _delete($_key) {
$this->put($_key,null,1);
function _delete($_key)
{
$this->put($_key, null, 1);
}
/**
@ -115,7 +139,8 @@ class CacheApc extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
function delete($key) {
function delete($key)
{
$this->_delete($key);
}
@ -124,10 +149,11 @@ class CacheApc extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
function truncate() {
function truncate()
{
return apc_clear_cache('user');
}
}
}
/* End of file CacheApc.class.php */
/* Location: ./classes/cache/CacheApc.class.php */