mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-14 16:02:14 +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
48
classes/cache/CacheWincache.class.php
vendored
48
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
|
||||
|
|
@ -19,9 +22,10 @@ class CacheWincache extends CacheBase {
|
|||
* @param void $opt Not used
|
||||
* @return CacheWincache instance of CacheWincache
|
||||
*/
|
||||
function getInstance($opt=null)
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,17 +55,20 @@ class CacheWincache extends CacheBase {
|
|||
* Adds a variable in user cache and overwrites a variable if it already exists in the cache
|
||||
*
|
||||
* @param string $key Store the variable using this $key value.
|
||||
* If a variable with same $key is already present the function will overwrite the previous value with the new one.
|
||||
* If a variable with same $key is already present the function will overwrite the previous value with the new one.
|
||||
* @param mixed $buff Value of a variable to store. $value supports all data types except resources, such as file handlers.
|
||||
* @param int $valid_time Time for the variable to live in the cache in seconds.
|
||||
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
|
||||
* If no ttl is supplied, use the default valid time CacheWincache::valid_time.
|
||||
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
|
||||
* If no ttl is supplied, use the default valid time CacheWincache::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 wincache_ucache_set(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
|
||||
if($valid_time == 0)
|
||||
{
|
||||
$valid_time = $this->valid_time;
|
||||
}
|
||||
return wincache_ucache_set(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -68,14 +76,17 @@ class CacheWincache 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 = 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])
|
||||
|
|
@ -83,7 +94,7 @@ class CacheWincache extends CacheBase {
|
|||
$this->_delete($_key);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -92,14 +103,17 @@ class CacheWincache extends CacheBase {
|
|||
*
|
||||
* @param string $key The $key that was used to store the variable in the cache.
|
||||
* @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 = 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])
|
||||
{
|
||||
|
|
@ -129,7 +143,7 @@ class CacheWincache extends CacheBase {
|
|||
*/
|
||||
function delete($key)
|
||||
{
|
||||
$_key = md5(_XE_PATH_.$key);
|
||||
$_key = md5(_XE_PATH_ . $key);
|
||||
$this->_delete($_key);
|
||||
}
|
||||
|
||||
|
|
@ -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