mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +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
96
classes/cache/CacheHandler.class.php
vendored
96
classes/cache/CacheHandler.class.php
vendored
|
|
@ -3,8 +3,9 @@
|
|||
* CacheHandler
|
||||
*
|
||||
* @author NHN (developer@xpressengine.com)
|
||||
**/
|
||||
class CacheHandler extends Handler {
|
||||
*/
|
||||
class CacheHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* instance of cache handler
|
||||
* @var CacheBase
|
||||
|
|
@ -25,9 +26,11 @@ class CacheHandler extends Handler {
|
|||
* @param boolean $always_use_file If set true, use a file cache always
|
||||
* @return CacheHandler
|
||||
*/
|
||||
function &getInstance($target = 'object', $info = null, $always_use_file = false) {
|
||||
function &getInstance($target = 'object', $info = null, $always_use_file = false)
|
||||
{
|
||||
$cache_handler_key = $target . ($always_use_file ? '_file' : '');
|
||||
if(!$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key]) {
|
||||
if(!$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key])
|
||||
{
|
||||
$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key] = new CacheHandler($target, $info, $always_use_file);
|
||||
}
|
||||
return $GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key];
|
||||
|
|
@ -44,34 +47,45 @@ class CacheHandler extends Handler {
|
|||
* @param boolean $always_use_file If set true, use a file cache always
|
||||
* @return CacheHandler
|
||||
*/
|
||||
function CacheHandler($target, $info = null, $always_use_file = false) {
|
||||
function CacheHandler($target, $info = null, $always_use_file = false)
|
||||
{
|
||||
if(!$info) $info = Context::getDBInfo();
|
||||
if($info){
|
||||
if($target == 'object'){
|
||||
if($info)
|
||||
{
|
||||
if($target == 'object')
|
||||
{
|
||||
if($info->use_object_cache =='apc') $type = 'apc';
|
||||
else if(substr($info->use_object_cache,0,8)=='memcache'){
|
||||
else if(substr($info->use_object_cache,0,8)=='memcache')
|
||||
{
|
||||
$type = 'memcache';
|
||||
$url = $info->use_object_cache;
|
||||
} else if($info->use_object_cache == 'wincache') $type = 'wincache';
|
||||
}
|
||||
else if($info->use_object_cache == 'wincache') $type = 'wincache';
|
||||
else if($info->use_object_cache =='file') $type = 'file';
|
||||
else if($always_use_file) $type = 'file';
|
||||
}else if($target == 'template'){
|
||||
}
|
||||
else if($target == 'template')
|
||||
{
|
||||
if($info->use_template_cache =='apc') $type = 'apc';
|
||||
else if(substr($info->use_template_cache,0,8)=='memcache'){
|
||||
else if(substr($info->use_template_cache,0,8)=='memcache')
|
||||
{
|
||||
$type = 'memcache';
|
||||
$url = $info->use_template_cache;
|
||||
} else if($info->use_template_cache == 'wincache') $type = 'wincache';
|
||||
}
|
||||
else if($info->use_template_cache == 'wincache') $type = 'wincache';
|
||||
}
|
||||
|
||||
if($type){
|
||||
if($type)
|
||||
{
|
||||
$class = 'Cache' . ucfirst($type);
|
||||
include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class);
|
||||
$this->handler = call_user_func(array($class,'getInstance'), $url);
|
||||
$this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
|
||||
if(!$this->keyGroupVersions) {
|
||||
$this->keyGroupVersions = array();
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
$this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
|
||||
if(!$this->keyGroupVersions)
|
||||
{
|
||||
$this->keyGroupVersions = array();
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +95,8 @@ class CacheHandler extends Handler {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSupport(){
|
||||
function isSupport()
|
||||
{
|
||||
if($this->handler && $this->handler->isSupport()) return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -94,7 +109,8 @@ class CacheHandler extends Handler {
|
|||
* 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)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
return $this->handler->get($key, $modified_time);
|
||||
}
|
||||
|
|
@ -109,7 +125,8 @@ class CacheHandler extends Handler {
|
|||
* If no ttl is supplied, use the default valid time.
|
||||
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
|
||||
*/
|
||||
function put($key, $obj, $valid_time = 0){
|
||||
function put($key, $obj, $valid_time = 0)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
return $this->handler->put($key, $obj, $valid_time);
|
||||
}
|
||||
|
|
@ -120,7 +137,8 @@ class CacheHandler extends Handler {
|
|||
* @param string $key Cache key
|
||||
* @return void
|
||||
*/
|
||||
function delete($key){
|
||||
function delete($key)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
return $this->handler->delete($key);
|
||||
}
|
||||
|
|
@ -133,7 +151,8 @@ class CacheHandler extends Handler {
|
|||
* 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){
|
||||
function isValid($key, $modified_time)
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
return $this->handler->isValid($key, $modified_time);
|
||||
}
|
||||
|
|
@ -143,7 +162,8 @@ class CacheHandler extends Handler {
|
|||
*
|
||||
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
|
||||
*/
|
||||
function truncate(){
|
||||
function truncate()
|
||||
{
|
||||
if(!$this->handler) return false;
|
||||
return $this->handler->truncate();
|
||||
}
|
||||
|
|
@ -164,8 +184,10 @@ class CacheHandler extends Handler {
|
|||
* @param string $key Cache key
|
||||
* @return string
|
||||
*/
|
||||
function getGroupKey($keyGroupName, $key){
|
||||
if(!$this->keyGroupVersions[$keyGroupName]){
|
||||
function getGroupKey($keyGroupName, $key)
|
||||
{
|
||||
if(!$this->keyGroupVersions[$keyGroupName])
|
||||
{
|
||||
$this->keyGroupVersions[$keyGroupName] = 1;
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
|
|
@ -179,7 +201,8 @@ class CacheHandler extends Handler {
|
|||
* @param string $keyGroupName Group name
|
||||
* @return void
|
||||
*/
|
||||
function invalidateGroupKey($keyGroupName){
|
||||
function invalidateGroupKey($keyGroupName)
|
||||
{
|
||||
$this->keyGroupVersions[$keyGroupName]++;
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
|
|
@ -190,8 +213,8 @@ class CacheHandler extends Handler {
|
|||
*
|
||||
* @author NHN (developer@xpressengine.com)
|
||||
*/
|
||||
class CacheBase{
|
||||
|
||||
class CacheBase
|
||||
{
|
||||
/**
|
||||
* Get cached data
|
||||
*
|
||||
|
|
@ -200,7 +223,8 @@ class 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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +238,8 @@ class CacheBase{
|
|||
* If no ttl is supplied, use the default valid time.
|
||||
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
|
||||
*/
|
||||
function put($key, $obj, $valid_time = 0){
|
||||
function put($key, $obj, $valid_time = 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +251,8 @@ class 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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +261,8 @@ class CacheBase{
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSupport(){
|
||||
function isSupport()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +271,8 @@ class CacheBase{
|
|||
*
|
||||
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
|
||||
*/
|
||||
function truncate(){
|
||||
function truncate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue