mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-23 20:32:14 +09:00
issue 2662 coding convention fix (in classes)
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12144 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f9fbd4a307
commit
cc1d9775ef
7 changed files with 186 additions and 94 deletions
51
classes/cache/CacheMemcache.class.php
vendored
51
classes/cache/CacheMemcache.class.php
vendored
|
|
@ -3,8 +3,9 @@
|
|||
* Cache class for memcache
|
||||
*
|
||||
* @author NHN (developer@xpressengine.com)
|
||||
**/
|
||||
class CacheMemcache extends CacheBase {
|
||||
*/
|
||||
class CacheMemcache extends CacheBase
|
||||
{
|
||||
/**
|
||||
* Default valid time
|
||||
* @var int
|
||||
|
|
@ -23,7 +24,8 @@ class CacheMemcache extends CacheBase {
|
|||
* @param string $url url of memcache
|
||||
* @return CacheMemcache instance of CacheMemcache
|
||||
*/
|
||||
function getInstance($url){
|
||||
function getInstance($url)
|
||||
{
|
||||
if(!$GLOBALS['__CacheMemcache__']) {
|
||||
$GLOBALS['__CacheMemcache__'] = new CacheMemcache($url);
|
||||
}
|
||||
|
|
@ -37,12 +39,14 @@ class CacheMemcache extends CacheBase {
|
|||
* @param string $url url of memcache
|
||||
* @return void
|
||||
*/
|
||||
function CacheMemcache($url){
|
||||
function CacheMemcache($url)
|
||||
{
|
||||
//$config['url'] = array('memcache://localhost:11211');
|
||||
$config['url'] = is_array($url)?$url:array($url);
|
||||
$this->Memcache = new Memcache;
|
||||
|
||||
foreach($config['url'] as $url) {
|
||||
foreach($config['url'] as $url)
|
||||
{
|
||||
$info = parse_url($url);
|
||||
$this->Memcache->addServer($info['host'], $info['port']);
|
||||
}
|
||||
|
|
@ -53,11 +57,15 @@ class CacheMemcache extends CacheBase {
|
|||
*
|
||||
* @return bool Return true on support or false on not support
|
||||
*/
|
||||
function isSupport(){
|
||||
function isSupport()
|
||||
{
|
||||
if($GLOBALS['XE_MEMCACHE_SUPPORT']) return true;
|
||||
if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1)) {
|
||||
if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1))
|
||||
{
|
||||
$GLOBALS['XE_MEMCACHE_SUPPORT'] = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['XE_MEMCACHE_SUPPORT'] = false;
|
||||
}
|
||||
return $GLOBALS['XE_MEMCACHE_SUPPORT'];
|
||||
|
|
@ -69,7 +77,8 @@ class CacheMemcache extends CacheBase {
|
|||
* @param string $key Cache key
|
||||
* @return string Return unique key
|
||||
*/
|
||||
function getKey($key){
|
||||
function getKey($key)
|
||||
{
|
||||
return md5(_XE_PATH_.$key);
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +99,8 @@ class CacheMemcache extends CacheBase {
|
|||
* If it's equal to zero, use the default valid time CacheMemcache::valid_time.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function put($key, $buff, $valid_time = 0){
|
||||
function put($key, $buff, $valid_time = 0)
|
||||
{
|
||||
if($valid_time == 0) $valid_time = $this->valid_time;
|
||||
|
||||
return $this->Memcache->set($this->getKey($key), array(time(), $buff), MEMCACHE_COMPRESSED, $valid_time);
|
||||
|
|
@ -104,14 +114,16 @@ class CacheMemcache extends CacheBase {
|
|||
* 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) {
|
||||
function isValid($key, $modified_time = 0)
|
||||
{
|
||||
$_key = $this->getKey($key);
|
||||
|
||||
$obj = $this->Memcache->get($_key);
|
||||
if(!$obj || !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;
|
||||
}
|
||||
|
|
@ -129,12 +141,14 @@ class CacheMemcache extends CacheBase {
|
|||
* 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) {
|
||||
function get($key, $modified_time = 0)
|
||||
{
|
||||
$_key = $this->getKey($key);
|
||||
$obj = $this->Memcache->get($_key);
|
||||
if(!$obj || !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;
|
||||
}
|
||||
|
|
@ -152,7 +166,8 @@ class CacheMemcache extends CacheBase {
|
|||
* @param string $key The key associated with the item to delete.
|
||||
* @return void
|
||||
*/
|
||||
function delete($key) {
|
||||
function delete($key)
|
||||
{
|
||||
$_key = $this->getKey($key);
|
||||
$this->_delete($_key);
|
||||
}
|
||||
|
|
@ -164,7 +179,8 @@ class CacheMemcache extends CacheBase {
|
|||
* @param string $_key The key associated with the item to delete.
|
||||
* @return void
|
||||
*/
|
||||
function _delete($_key) {
|
||||
function _delete($_key)
|
||||
{
|
||||
$this->Memcache->delete($_key);
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +193,8 @@ class CacheMemcache extends CacheBase {
|
|||
*
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function truncate() {
|
||||
function truncate()
|
||||
{
|
||||
return $this->Memcache->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue