mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-17 18:29:55 +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
72
classes/cache/CacheApc.class.php
vendored
72
classes/cache/CacheApc.class.php
vendored
|
|
@ -1,14 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @class CacheApc
|
||||
* Cache class for APC
|
||||
*
|
||||
* @author NHN (developer@xpressengine.com)
|
||||
* @brief APC Handler
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class CacheApc extends CacheBase {
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
*/
|
||||
var $valid_time = 36000;
|
||||
|
||||
/**
|
||||
* Get instance of CacheApc
|
||||
*
|
||||
* @param void $opt Not used
|
||||
* @return CacheApc instance of CacheApc
|
||||
*/
|
||||
function getInstance($opt=null){
|
||||
if(!$GLOBALS['__CacheApc__']) {
|
||||
$GLOBALS['__CacheApc__'] = new CacheApc();
|
||||
|
|
@ -16,18 +24,46 @@ class CacheApc extends CacheBase {
|
|||
return $GLOBALS['__CacheApc__'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function CacheApc(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether support or not support cache
|
||||
*
|
||||
* @return bool Return true on support or false on not support
|
||||
*/
|
||||
function isSupport(){
|
||||
return function_exists('apc_add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache a variable in the data store
|
||||
*
|
||||
* @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.
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether cache is valid or invalid
|
||||
*
|
||||
* @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.
|
||||
* @return bool Return true on valid or false on invalid.
|
||||
*/
|
||||
function isValid($key, $modified_time = 0) {
|
||||
$_key = md5(_XE_PATH_.$key);
|
||||
$obj = apc_fetch($_key, $success);
|
||||
|
|
@ -42,6 +78,14 @@ class CacheApc extends CacheBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a stored variable from the cache
|
||||
*
|
||||
* @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.
|
||||
* @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);
|
||||
$obj = apc_fetch($_key, $success);
|
||||
|
|
@ -55,15 +99,31 @@ class CacheApc extends CacheBase {
|
|||
return $obj[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variable from the cache(private)
|
||||
*
|
||||
* @param string $_key Used to store the value.
|
||||
* @return void
|
||||
*/
|
||||
function _delete($_key) {
|
||||
$this->put($_key,null,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variable from the cache
|
||||
*
|
||||
* @param string $key Used to store the value.
|
||||
* @return void
|
||||
*/
|
||||
function delete($key) {
|
||||
$_key = md5(_XE_PATH_.$key);
|
||||
$this->_delete($_key);
|
||||
$this->_delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate all existing variables at the cache
|
||||
*
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function truncate() {
|
||||
return apc_clear_cache('user');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue