Merge 1.5.2.3 (~r10623)

git-svn-id: http://xe-core.googlecode.com/svn/trunk@10624 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2012-04-26 09:17:29 +00:00
parent 79fdf10866
commit e4306a789f
915 changed files with 71076 additions and 245 deletions

View file

@ -60,7 +60,8 @@ class CacheApc extends CacheBase {
}
function delete($key) {
$this->_delete($key);
$_key = md5(_XE_PATH_.$key);
$this->_delete($_key);
}
function truncate() {

69
classes/cache/CacheFile.class.php vendored Normal file
View file

@ -0,0 +1,69 @@
<?php
/**
* @class CacheFile
* @author Arnia Software (xe_dev@arnia.ro)
* @brief Filedisk Cache Handler
* @version 0.1
**/
class CacheFile extends CacheBase {
var $valid_time = 36000;
var $cache_dir = 'files/cache/store/';
function getInstance(){
if(!$GLOBALS['__CacheFile__']) {
$GLOBALS['__CacheFile__'] = new CacheFile();
}
return $GLOBALS['__CacheFile__'];
}
function CacheFile(){
$this->cache_dir = _XE_PATH_ . $this->cache_dir;
if(!is_dir($this->cache_dir)) FileHandler::makeDir($this->cache_dir);
}
private function getCacheFileName($key){
return $this->cache_dir . str_replace(':', '_', $key);
}
function isSupport(){
return true;
}
function put($key, $obj, $valid_time = 0){
$cache_file = $this->getCacheFileName($key);
$text = serialize($obj);
FileHandler::writeFile($cache_file, $text);
}
function isValid($key, $modified_time = 0) {
$cache_file = $this->getCacheFileName($key);
if(file_exists($cache_file)) return true;
return false;
}
function get($key, $modified_time = 0) {
$cache_file = $this->getCacheFileName($key);
$content = FileHandler::readFile($cache_file);
if(!$content) return false;
return unserialize($content);
}
function _delete($_key) {
$cache_file = $this->getCacheFileName($_key);
FileHandler::removeFile($cache_file);
}
function delete($key) {
$this->_delete($key);
}
function truncate() {
FileHandler::removeFilesInDir($this->cache_dir);
}
}
/* End of file CacheFile.class.php */
/* Location: ./classes/cache/CacheFile.class.php */

View file

@ -10,14 +10,15 @@ class CacheHandler extends Handler {
var $handler = null;
var $keyGroupVersions = null;
function &getInstance($target = 'object') {
if(!$GLOBALS['__XE_CACHE_HANDLER__'][$target]) {
$GLOBALS['__XE_CACHE_HANDLER__'][$target] = new CacheHandler($target);
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]) {
$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key] = new CacheHandler($target, $info, $always_use_file);
}
return $GLOBALS['__XE_CACHE_HANDLER__'][$target];
return $GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key];
}
function CacheHandler($target, $info = null) {
function CacheHandler($target, $info = null, $always_use_file = false) {
if(!$info) $info = Context::getDBInfo();
if($info){
if($target == 'object'){
@ -25,13 +26,15 @@ class CacheHandler extends Handler {
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 =='file') $type = 'file';
else if($always_use_file) $type = 'file';
}else if($target == 'template'){
if($info->use_template_cache =='apc') $type = 'apc';
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';
}
if($type){

73
classes/cache/CacheWincache.class.php vendored Normal file
View file

@ -0,0 +1,73 @@
<?php
/**
* @class CacheWincache
* @author Arnia (support@xpressengine.org)
* @brief Wincache Handler
* @version 0.1
**/
class CacheWincache extends CacheBase {
var $valid_time = 36000;
function getInstance($opt=null){
if(!$GLOBALS['__CacheWincache__']) {
$GLOBALS['__CacheWincache__'] = new CacheWincache();
}
return $GLOBALS['__CacheWincache__'];
}
function CacheWincache(){
}
function isSupport(){
return function_exists('wincache_ucache_set');
}
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);
}
function isValid($key, $modified_time = 0) {
$_key = md5(_XE_PATH_.$key);
$obj = wincache_ucache_get($_key, $success);
if(!$success || !is_array($obj)) return false;
unset($obj[1]);
if($modified_time > 0 && $modified_time > $obj[0]) {
$this->_delete($_key);
return false;
}
return true;
}
function get($key, $modified_time = 0) {
$_key = md5(_XE_PATH_.$key);
$obj = wincache_ucache_get($_key, $success);
if(!$success || !is_array($obj)) return false;
if($modified_time > 0 && $modified_time > $obj[0]) {
$this->_delete($_key);
return false;
}
return $obj[1];
}
function _delete($_key) {
wincache_ucache_delete($_key);
}
function delete($key) {
$_key = md5(_XE_PATH_.$key);
$this->_delete($_key);
}
function truncate() {
return wincache_ucache_clear();
}
}
/* End of file CacheWincache.class.php */
/* Location: ./classes/cache/CacheWincache.class.php */