mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
r500
Префикс кеша git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@500 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
parent
ebad74456a
commit
095aedea24
2 changed files with 180 additions and 104 deletions
|
@ -142,7 +142,7 @@ class CACHES
|
||||||
case 'memcache':
|
case 'memcache':
|
||||||
if (!isset($this->obj[$cache_name]))
|
if (!isset($this->obj[$cache_name]))
|
||||||
{
|
{
|
||||||
$this->obj[$cache_name] = new cache_memcache($this->cfg['memcache']);
|
$this->obj[$cache_name] = new cache_memcache($this->cfg['memcache'], $this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -153,7 +153,7 @@ class CACHES
|
||||||
$cache_cfg['pconnect'] = $this->cfg['pconnect'];
|
$cache_cfg['pconnect'] = $this->cfg['pconnect'];
|
||||||
$cache_cfg['db_file_path'] = $this->get_db_path($cache_name, $cache_cfg, '.sqlite.db');
|
$cache_cfg['db_file_path'] = $this->get_db_path($cache_name, $cache_cfg, '.sqlite.db');
|
||||||
|
|
||||||
$this->obj[$cache_name] = new cache_sqlite($cache_cfg);
|
$this->obj[$cache_name] = new cache_sqlite($cache_cfg, $this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -174,7 +174,7 @@ class CACHES
|
||||||
case 'redis':
|
case 'redis':
|
||||||
if (!isset($this->obj[$cache_name]))
|
if (!isset($this->obj[$cache_name]))
|
||||||
{
|
{
|
||||||
$this->obj[$cache_name] = new cache_redis($this->cfg['redis']);
|
$this->obj[$cache_name] = new cache_redis($this->cfg['redis'], $this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -182,7 +182,7 @@ class CACHES
|
||||||
case 'eaccelerator':
|
case 'eaccelerator':
|
||||||
if (!isset($this->obj[$cache_name]))
|
if (!isset($this->obj[$cache_name]))
|
||||||
{
|
{
|
||||||
$this->obj[$cache_name] = new cache_eaccelerator();
|
$this->obj[$cache_name] = new cache_eaccelerator($this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -190,7 +190,7 @@ class CACHES
|
||||||
case 'apc':
|
case 'apc':
|
||||||
if (!isset($this->obj[$cache_name]))
|
if (!isset($this->obj[$cache_name]))
|
||||||
{
|
{
|
||||||
$this->obj[$cache_name] = new cache_apc();
|
$this->obj[$cache_name] = new cache_apc($this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -198,7 +198,7 @@ class CACHES
|
||||||
case 'xcache':
|
case 'xcache':
|
||||||
if (!isset($this->obj[$cache_name]))
|
if (!isset($this->obj[$cache_name]))
|
||||||
{
|
{
|
||||||
$this->obj[$cache_name] = new cache_xcache();
|
$this->obj[$cache_name] = new cache_xcache($this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -206,7 +206,7 @@ class CACHES
|
||||||
default: //filecache
|
default: //filecache
|
||||||
if (!isset($this->obj[$cache_name]))
|
if (!isset($this->obj[$cache_name]))
|
||||||
{
|
{
|
||||||
$this->obj[$cache_name] = new cache_file($this->cfg['db_dir'] . $cache_name .'/');
|
$this->obj[$cache_name] = new cache_file($this->cfg['db_dir'] . $cache_name .'/', $this->cfg['prefix']);
|
||||||
}
|
}
|
||||||
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
$this->ref[$cache_name] =& $this->obj[$cache_name];
|
||||||
break;
|
break;
|
||||||
|
@ -245,16 +245,14 @@ function CACHE ($cache_name)
|
||||||
|
|
||||||
class cache_common
|
class cache_common
|
||||||
{
|
{
|
||||||
var $prefix = 'tp2_'; // Для использования нескольких проектов на одном сервере
|
|
||||||
|
|
||||||
var $used = false;
|
var $used = false;
|
||||||
/**
|
/**
|
||||||
* Returns value of variable
|
* Returns value of variable
|
||||||
*/
|
*/
|
||||||
function get ($name, $get_miss_key_callback = '', $ttl = 604800)
|
function get ($name, $get_miss_key_callback = '', $ttl = 604800)
|
||||||
{
|
{
|
||||||
if ($get_miss_key_callback) return $get_miss_key_callback($this->prefix . $name);
|
if ($get_miss_key_callback) return $get_miss_key_callback($name);
|
||||||
return is_array($this->prefix . $name) ? array() : false;
|
return is_array($name) ? array() : false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Store value of variable
|
* Store value of variable
|
||||||
|
@ -331,10 +329,11 @@ class cache_memcache extends cache_common
|
||||||
var $used = true;
|
var $used = true;
|
||||||
var $engine = 'Memcache';
|
var $engine = 'Memcache';
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
|
var $prefix = null;
|
||||||
var $memcache = null;
|
var $memcache = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
|
|
||||||
function cache_memcache ($cfg)
|
function cache_memcache ($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
|
@ -342,6 +341,7 @@ class cache_memcache extends cache_common
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
|
$this->prefix = $prefix;
|
||||||
$this->memcache = new Memcache;
|
$this->memcache = new Memcache;
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
@ -401,6 +401,12 @@ class cache_memcache extends cache_common
|
||||||
|
|
||||||
if ($name)
|
if ($name)
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->rm('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return ($this->connected) ? $this->memcache->delete($this->prefix . $name, 0) : false;
|
return ($this->connected) ? $this->memcache->delete($this->prefix . $name, 0) : false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -419,6 +425,7 @@ class cache_sqlite extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
var $db = null;
|
var $db = null;
|
||||||
|
var $prefix = null;
|
||||||
var $cfg = array(
|
var $cfg = array(
|
||||||
'db_file_path' => '/path/to/cache.db.sqlite',
|
'db_file_path' => '/path/to/cache.db.sqlite',
|
||||||
'table_name' => 'cache',
|
'table_name' => 'cache',
|
||||||
|
@ -433,17 +440,18 @@ class cache_sqlite extends cache_common
|
||||||
'log_name' => 'CACHE',
|
'log_name' => 'CACHE',
|
||||||
);
|
);
|
||||||
|
|
||||||
function cache_sqlite ($cfg)
|
function cache_sqlite ($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
$this->cfg = array_merge($this->cfg, $cfg);
|
$this->cfg = array_merge($this->cfg, $cfg);
|
||||||
$this->db = new sqlite_common($this->cfg);
|
$this->db = new sqlite_common($this->cfg);
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name, $get_miss_key_callback = '', $ttl = 604800)
|
function get ($name, $get_miss_key_callback = '', $ttl = 604800)
|
||||||
{
|
{
|
||||||
if (empty($name))
|
if (empty($name))
|
||||||
{
|
{
|
||||||
return is_array( $name) ? array() : false;
|
return is_array($name) ? array() : false;
|
||||||
}
|
}
|
||||||
$this->db->shard($name);
|
$this->db->shard($name);
|
||||||
$cached_items = array();
|
$cached_items = array();
|
||||||
|
@ -698,9 +706,10 @@ class cache_redis extends cache_common
|
||||||
var $engine = 'Redis';
|
var $engine = 'Redis';
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
var $redis = null;
|
var $redis = null;
|
||||||
|
var $prefix = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
|
|
||||||
function cache_redis ($cfg)
|
function cache_redis ($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
|
@ -708,6 +717,7 @@ class cache_redis extends cache_common
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
|
$this->prefix = $prefix;
|
||||||
$this->redis = new Redis();
|
$this->redis = new Redis();
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
@ -776,6 +786,12 @@ class cache_redis extends cache_common
|
||||||
|
|
||||||
if ($name)
|
if ($name)
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->rm('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return ($this->connected) ? $this->redis->del($this->prefix . $name) : false;
|
return ($this->connected) ? $this->redis->del($this->prefix . $name) : false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -794,14 +810,16 @@ class cache_eaccelerator extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
var $engine = 'eAccelerator';
|
var $engine = 'eAccelerator';
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function cache_eaccelerator ()
|
function cache_eaccelerator ($prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: eAccelerator extension not installed');
|
die('Error: eAccelerator extension not installed');
|
||||||
}
|
}
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name, $get_miss_key_callback = '', $ttl = 0)
|
function get ($name, $get_miss_key_callback = '', $ttl = 0)
|
||||||
|
@ -828,6 +846,12 @@ class cache_eaccelerator extends cache_common
|
||||||
|
|
||||||
function rm ($name = '')
|
function rm ($name = '')
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->rm('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return eaccelerator_rm($this->prefix . $name);
|
return eaccelerator_rm($this->prefix . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,14 +865,16 @@ class cache_apc extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
var $engine = 'APC';
|
var $engine = 'APC';
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function cache_apc ()
|
function cache_apc ($prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: APC extension not installed');
|
die('Error: APC extension not installed');
|
||||||
}
|
}
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name, $get_miss_key_callback = '', $ttl = 0)
|
function get ($name, $get_miss_key_callback = '', $ttl = 0)
|
||||||
|
@ -877,6 +903,12 @@ class cache_apc extends cache_common
|
||||||
{
|
{
|
||||||
if ($name)
|
if ($name)
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->rm('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return apc_delete($this->prefix . $name);
|
return apc_delete($this->prefix . $name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -895,14 +927,16 @@ class cache_xcache extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
var $engine = 'XCache';
|
var $engine = 'XCache';
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function cache_xcache ()
|
function cache_xcache ($prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: XCache extension not installed');
|
die('Error: XCache extension not installed');
|
||||||
}
|
}
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name, $get_miss_key_callback = '', $ttl = 0)
|
function get ($name, $get_miss_key_callback = '', $ttl = 0)
|
||||||
|
@ -931,12 +965,18 @@ class cache_xcache extends cache_common
|
||||||
{
|
{
|
||||||
if ($name)
|
if ($name)
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->rm('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return xcache_unset($this->prefix . $name);
|
return xcache_unset($this->prefix . $name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xcache_clear_cache(XC_TYPE_PHP, 1);
|
xcache_clear_cache(XC_TYPE_PHP, 0);
|
||||||
xcache_clear_cache(XC_TYPE_VAR, 1);
|
xcache_clear_cache(XC_TYPE_VAR, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -952,10 +992,12 @@ class cache_file extends cache_common
|
||||||
var $used = true;
|
var $used = true;
|
||||||
var $engine = 'Filecache';
|
var $engine = 'Filecache';
|
||||||
var $dir = null;
|
var $dir = null;
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function cache_file ($dir)
|
function cache_file ($dir, $prefix = null)
|
||||||
{
|
{
|
||||||
$this->dir = $dir;
|
$this->dir = $dir;
|
||||||
|
$this->prefix = $prefix;
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,11 +1053,18 @@ class cache_file extends cache_common
|
||||||
$clear = false;
|
$clear = false;
|
||||||
if ($name)
|
if ($name)
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->rm('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
|
||||||
$filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
|
$filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
|
||||||
if (file_exists($filename))
|
if (file_exists($filename))
|
||||||
{
|
{
|
||||||
$clear = (bool) unlink($filename);
|
$clear = (bool) unlink($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1252,8 +1301,9 @@ class datastore_memcache extends datastore_common
|
||||||
var $memcache = null;
|
var $memcache = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
var $engine = 'Memcache';
|
var $engine = 'Memcache';
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function datastore_memcache ($cfg)
|
function datastore_memcache ($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
global $bb_cfg;
|
||||||
|
|
||||||
|
@ -1263,6 +1313,7 @@ class datastore_memcache extends datastore_common
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
|
$this->prefix = $prefix;
|
||||||
$this->memcache = new Memcache;
|
$this->memcache = new Memcache;
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1352,7 @@ class datastore_memcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
return (bool) $this->memcache->set($title, $var);
|
return (bool) $this->memcache->set($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean ()
|
function clean ()
|
||||||
|
@ -1315,7 +1366,7 @@ class datastore_memcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->memcache->delete($title, 0);
|
$this->memcache->delete($this->prefix . $title, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1336,7 +1387,7 @@ class datastore_memcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->data[$item] = $this->memcache->get($item);
|
$this->data[$item] = $this->memcache->get($this->prefix . $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1350,6 +1401,7 @@ class datastore_sqlite extends datastore_common
|
||||||
{
|
{
|
||||||
var $engine = 'SQLite';
|
var $engine = 'SQLite';
|
||||||
var $db = null;
|
var $db = null;
|
||||||
|
var $prefix = null;
|
||||||
var $cfg = array(
|
var $cfg = array(
|
||||||
'db_file_path' => '/path/to/datastore.db.sqlite',
|
'db_file_path' => '/path/to/datastore.db.sqlite',
|
||||||
'table_name' => 'datastore',
|
'table_name' => 'datastore',
|
||||||
|
@ -1363,17 +1415,18 @@ class datastore_sqlite extends datastore_common
|
||||||
'log_name' => 'DATASTORE',
|
'log_name' => 'DATASTORE',
|
||||||
);
|
);
|
||||||
|
|
||||||
function datastore_sqlite ($cfg)
|
function datastore_sqlite ($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
$this->cfg = array_merge($this->cfg, $cfg);
|
$this->cfg = array_merge($this->cfg, $cfg);
|
||||||
$this->db = new sqlite_common($this->cfg);
|
$this->db = new sqlite_common($this->cfg);
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($item_name, $item_data)
|
function store ($item_name, $item_data)
|
||||||
{
|
{
|
||||||
$this->data[$item_name] = $item_data;
|
$this->data[$item_name] = $item_data;
|
||||||
|
|
||||||
$ds_title = sqlite_escape_string($item_name);
|
$ds_title = sqlite_escape_string($this->prefix . $item_name);
|
||||||
$ds_data = sqlite_escape_string(serialize($item_data));
|
$ds_data = sqlite_escape_string(serialize($item_data));
|
||||||
|
|
||||||
$result = $this->db->query("REPLACE INTO ". $this->cfg['table_name'] ." (ds_title, ds_data) VALUES ('$ds_title', '$ds_data')");
|
$result = $this->db->query("REPLACE INTO ". $this->cfg['table_name'] ." (ds_title, ds_data) VALUES ('$ds_title', '$ds_data')");
|
||||||
|
@ -1390,15 +1443,18 @@ class datastore_sqlite extends datastore_common
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) return;
|
if (!$items = $this->queued_items) return;
|
||||||
|
|
||||||
array_deep($items, 'sqlite_escape_string');
|
$prefix_len = strlen($this->prefix);
|
||||||
$items_list = join("','", $items);
|
$prefix_sql = sqlite_escape_string($this->prefix);
|
||||||
|
|
||||||
$rowset = $this->db->fetch_rowset("SELECT ds_title, ds_data FROM ". $this->cfg['table_name'] ." WHERE ds_title IN('$items_list')");
|
array_deep($items, 'sqlite_escape_string');
|
||||||
|
$items_list = $prefix_sql . join("','$prefix_sql", $items);
|
||||||
|
|
||||||
|
$rowset = $this->db->fetch_rowset("SELECT ds_title, ds_data FROM ". $this->cfg['table_name'] ." WHERE ds_title IN ('$items_list')");
|
||||||
|
|
||||||
$this->db->debug('start', "unserialize()");
|
$this->db->debug('start', "unserialize()");
|
||||||
foreach ($rowset as $row)
|
foreach ($rowset as $row)
|
||||||
{
|
{
|
||||||
$this->data[$row['ds_title']] = unserialize($row['ds_data']);
|
$this->data[substr($row['ds_title'], $prefix_len)] = unserialize($row['ds_data']);
|
||||||
}
|
}
|
||||||
$this->db->debug('stop');
|
$this->db->debug('stop');
|
||||||
}
|
}
|
||||||
|
@ -1408,10 +1464,11 @@ class datastore_redis extends datastore_common
|
||||||
{
|
{
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
var $redis = null;
|
var $redis = null;
|
||||||
|
var $prefix = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
var $engine = 'Redis';
|
var $engine = 'Redis';
|
||||||
|
|
||||||
function datastore_redis ($cfg)
|
function datastore_redis ($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
global $bb_cfg;
|
||||||
|
|
||||||
|
@ -1423,6 +1480,7 @@ class datastore_redis extends datastore_common
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
$this->redis = new Redis();
|
$this->redis = new Redis();
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect ()
|
function connect ()
|
||||||
|
@ -1455,7 +1513,7 @@ class datastore_redis extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
return (bool) $this->redis->set($title, serialize($var));
|
return (bool) $this->redis->set($this->prefix . $title, serialize($var));
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean ()
|
function clean ()
|
||||||
|
@ -1469,7 +1527,7 @@ class datastore_redis extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->redis->del($title);
|
$this->redis->del($this->prefix . $title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1490,7 +1548,7 @@ class datastore_redis extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->data[$item] = unserialize($this->redis->get($item));
|
$this->data[$item] = unserialize($this->redis->get($this->prefix . $item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1503,14 +1561,18 @@ class datastore_redis extends datastore_common
|
||||||
class datastore_eaccelerator extends datastore_common
|
class datastore_eaccelerator extends datastore_common
|
||||||
{
|
{
|
||||||
var $engine = 'eAccelerator';
|
var $engine = 'eAccelerator';
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function datastore_eaccelerator ()
|
function datastore_eaccelerator ($prefix = null)
|
||||||
{
|
{
|
||||||
|
global $bb_cfg;
|
||||||
|
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: eAccelerator extension not installed');
|
die('Error: eAccelerator extension not installed');
|
||||||
}
|
}
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($title, $var)
|
function store ($title, $var)
|
||||||
|
@ -1523,7 +1585,7 @@ class datastore_eaccelerator extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
eaccelerator_put($title, $var);
|
eaccelerator_put($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean ()
|
function clean ()
|
||||||
|
@ -1536,7 +1598,7 @@ class datastore_eaccelerator extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
eaccelerator_rm($title);
|
eaccelerator_rm($this->prefix . $title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1556,7 +1618,7 @@ class datastore_eaccelerator extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->data[$item] = eaccelerator_get($item);
|
$this->data[$item] = eaccelerator_get($this->prefix . $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1568,15 +1630,20 @@ class datastore_eaccelerator extends datastore_common
|
||||||
|
|
||||||
class datastore_xcache extends datastore_common
|
class datastore_xcache extends datastore_common
|
||||||
{
|
{
|
||||||
|
var $prefix = null;
|
||||||
var $engine = 'XCache';
|
var $engine = 'XCache';
|
||||||
|
|
||||||
function cache_xcache ()
|
function datastore_xcache ($prefix = null)
|
||||||
{
|
{
|
||||||
|
global $bb_cfg;
|
||||||
|
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: XCache extension not installed');
|
die('Error: XCache extension not installed');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($title, $var)
|
function store ($title, $var)
|
||||||
|
@ -1589,7 +1656,7 @@ class datastore_xcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
return (bool) xcache_set($title, $var);
|
return (bool) xcache_set($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean ()
|
function clean ()
|
||||||
|
@ -1602,7 +1669,7 @@ class datastore_xcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
xcache_unset($title);
|
xcache_unset($this->prefix . $title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,7 +1689,7 @@ class datastore_xcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->data[$item] = xcache_get($item);
|
$this->data[$item] = xcache_get($this->prefix . $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1635,14 +1702,18 @@ class datastore_xcache extends datastore_common
|
||||||
class datastore_apc extends datastore_common
|
class datastore_apc extends datastore_common
|
||||||
{
|
{
|
||||||
var $engine = 'APC';
|
var $engine = 'APC';
|
||||||
|
var $prefix = null;
|
||||||
|
|
||||||
function datastore_apc ()
|
function datastore_apc ($prefix = null)
|
||||||
{
|
{
|
||||||
|
global $bb_cfg;
|
||||||
|
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: APC extension not installed');
|
die('Error: APC extension not installed');
|
||||||
}
|
}
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($title, $var)
|
function store ($title, $var)
|
||||||
|
@ -1655,7 +1726,7 @@ class datastore_apc extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
return (bool) apc_store($title, $var);
|
return (bool) apc_store($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean ()
|
function clean ()
|
||||||
|
@ -1668,7 +1739,7 @@ class datastore_apc extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
apc_delete($title);
|
apc_delete($this->prefix . $title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1688,7 +1759,7 @@ class datastore_apc extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
|
|
||||||
$this->data[$item] = apc_fetch($item);
|
$this->data[$item] = apc_fetch($this->prefix . $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,10 +1772,14 @@ class datastore_apc extends datastore_common
|
||||||
class datastore_file extends datastore_common
|
class datastore_file extends datastore_common
|
||||||
{
|
{
|
||||||
var $dir = null;
|
var $dir = null;
|
||||||
|
var $prefix = null;
|
||||||
var $engine = 'Filecache';
|
var $engine = 'Filecache';
|
||||||
|
|
||||||
function datastore_file ($dir)
|
function datastore_file ($dir, $prefix = null)
|
||||||
{
|
{
|
||||||
|
global $bb_cfg;
|
||||||
|
|
||||||
|
$this->prefix = $prefix;
|
||||||
$this->dir = $dir;
|
$this->dir = $dir;
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
@ -1716,7 +1791,7 @@ class datastore_file extends datastore_common
|
||||||
|
|
||||||
$this->data[$title] = $var;
|
$this->data[$title] = $var;
|
||||||
|
|
||||||
$filename = $this->dir . clean_filename($title) . '.php';
|
$filename = $this->dir . clean_filename($this->prefix . $title) . '.php';
|
||||||
|
|
||||||
$filecache = "<?php\n";
|
$filecache = "<?php\n";
|
||||||
$filecache .= "if (!defined('BB_ROOT')) die(basename(__FILE__));\n";
|
$filecache .= "if (!defined('BB_ROOT')) die(basename(__FILE__));\n";
|
||||||
|
@ -1762,7 +1837,7 @@ class datastore_file extends datastore_common
|
||||||
|
|
||||||
foreach($items as $item)
|
foreach($items as $item)
|
||||||
{
|
{
|
||||||
$filename = $this->dir . $item . '.php';
|
$filename = $this->dir . $this->prefix . $item . '.php';
|
||||||
|
|
||||||
$this->cur_query = "cache->get('$item')";
|
$this->cur_query = "cache->get('$item')";
|
||||||
$this->debug('start');
|
$this->debug('start');
|
||||||
|
@ -1784,7 +1859,7 @@ class datastore_file extends datastore_common
|
||||||
switch ($bb_cfg['datastore_type'])
|
switch ($bb_cfg['datastore_type'])
|
||||||
{
|
{
|
||||||
case 'memcache':
|
case 'memcache':
|
||||||
$datastore = new datastore_memcache($bb_cfg['cache']['memcache']);
|
$datastore = new datastore_memcache($bb_cfg['cache']['memcache'], $bb_cfg['cache']['prefix']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sqlite':
|
case 'sqlite':
|
||||||
|
@ -1793,27 +1868,27 @@ switch ($bb_cfg['datastore_type'])
|
||||||
'pconnect' => true,
|
'pconnect' => true,
|
||||||
'con_required' => true,
|
'con_required' => true,
|
||||||
);
|
);
|
||||||
$datastore = new datastore_sqlite($default_cfg);
|
$datastore = new datastore_sqlite($default_cfg, $bb_cfg['cache']['prefix']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'redis':
|
case 'redis':
|
||||||
$datastore = new datastore_redis($bb_cfg['cache']['redis']);
|
$datastore = new datastore_redis($bb_cfg['cache']['redis'], $bb_cfg['cache']['prefix']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'eaccelerator':
|
case 'eaccelerator':
|
||||||
$datastore = new datastore_eaccelerator();
|
$datastore = new datastore_eaccelerator($bb_cfg['cache']['prefix']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'xcache':
|
case 'xcache':
|
||||||
$datastore = new datastore_xcache();
|
$datastore = new datastore_xcache($bb_cfg['cache']['prefix']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'apc':
|
case 'apc':
|
||||||
$datastore = new datastore_apc();
|
$datastore = new datastore_apc($bb_cfg['cache']['prefix']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'filecache':
|
case 'filecache':
|
||||||
default: $datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/');
|
default: $datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sql_dbg_enabled ()
|
function sql_dbg_enabled ()
|
||||||
|
|
|
@ -56,8 +56,8 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do
|
||||||
|
|
||||||
// Increase number of revision after update
|
// Increase number of revision after update
|
||||||
$bb_cfg['tp_version'] = '2.5 pre-stable';
|
$bb_cfg['tp_version'] = '2.5 pre-stable';
|
||||||
$bb_cfg['tp_release_date'] = '14-04-2013';
|
$bb_cfg['tp_release_date'] = '15-05-2013';
|
||||||
$bb_cfg['tp_release_state'] = 'R499';
|
$bb_cfg['tp_release_state'] = 'R500';
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
$charset = 'utf8';
|
$charset = 'utf8';
|
||||||
|
@ -77,6 +77,7 @@ $bb_cfg['db_alias'] = array(
|
||||||
// Cache
|
// Cache
|
||||||
$bb_cfg['cache']['pconnect'] = true;
|
$bb_cfg['cache']['pconnect'] = true;
|
||||||
$bb_cfg['cache']['db_dir'] = realpath(BB_ROOT) .'/cache/filecache/';
|
$bb_cfg['cache']['db_dir'] = realpath(BB_ROOT) .'/cache/filecache/';
|
||||||
|
$bb_cfg['cache']['prefix'] = ''; // Префикс кеша 'tp_2'
|
||||||
$bb_cfg['cache']['memcache'] = array(
|
$bb_cfg['cache']['memcache'] = array(
|
||||||
'host' => '127.0.0.1',
|
'host' => '127.0.0.1',
|
||||||
'port' => 11211,
|
'port' => 11211,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue