mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
Change internal representation of cache groups
This commit is contained in:
parent
3117621270
commit
8d733f1928
10 changed files with 75 additions and 12 deletions
|
|
@ -55,12 +55,23 @@ class Cache
|
||||||
|
|
||||||
if (class_exists($class_name) && $class_name::isSupported())
|
if (class_exists($class_name) && $class_name::isSupported())
|
||||||
{
|
{
|
||||||
return self::$_driver = new $class_name($config);
|
self::$_driver = new $class_name($config);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return self::$_driver = new Drivers\Cache\File(array());
|
self::$_driver = new Drivers\Cache\File(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self::$_driver->prefix)
|
||||||
|
{
|
||||||
|
self::$_prefix = substr(sha1(\RX_BASEDIR), 0, 10) . ':' . \RX_VERSION . ':';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self::$_prefix = \RX_VERSION . ':';
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$_driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -117,11 +128,6 @@ class Cache
|
||||||
*/
|
*/
|
||||||
public static function getCachePrefix()
|
public static function getCachePrefix()
|
||||||
{
|
{
|
||||||
if (self::$_prefix === null)
|
|
||||||
{
|
|
||||||
self::$_prefix = substr(sha1(\RX_BASEDIR), 0, 10) . ':' . \RX_VERSION . ':';
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$_prefix;
|
return self::$_prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +239,7 @@ class Cache
|
||||||
{
|
{
|
||||||
if (self::$_driver !== null)
|
if (self::$_driver !== null)
|
||||||
{
|
{
|
||||||
return self::$_driver->incr(self::getRealKey('#GROUP:' . $group_name . ':v'), 1) ? true : false;
|
return self::$_driver->incr(self::$_prefix . $group_name . '#version', 1) ? true : false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -260,6 +266,24 @@ class Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the group version.
|
||||||
|
*
|
||||||
|
* @param string $group_name
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getGroupVersion($group_name)
|
||||||
|
{
|
||||||
|
if (self::$_driver !== null)
|
||||||
|
{
|
||||||
|
return intval(self::$_driver->get(self::$_prefix . $group_name . '#version'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the actual key used by Rhymix.
|
* Get the actual key used by Rhymix.
|
||||||
*
|
*
|
||||||
|
|
@ -272,10 +296,9 @@ class Cache
|
||||||
{
|
{
|
||||||
if ($group_name)
|
if ($group_name)
|
||||||
{
|
{
|
||||||
$group_version = intval(self::get('#GROUP:' . $group_name . ':v'));
|
$key = $group_name . '#' . self::getGroupVersion($group_name) . ':' . $key;
|
||||||
$key = '#GROUP:' . $group_name . ':' . $group_version . ':' . $key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($add_prefix ? self::getCachePrefix() : '') . $key;
|
return ($add_prefix ? self::$_prefix : '') . $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/apc.php
vendored
5
common/framework/drivers/cache/apc.php
vendored
|
|
@ -7,6 +7,11 @@ namespace Rhymix\Framework\Drivers\Cache;
|
||||||
*/
|
*/
|
||||||
class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of the current cache driver, using the given settings.
|
* Create a new instance of the current cache driver, using the given settings.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/dummy.php
vendored
5
common/framework/drivers/cache/dummy.php
vendored
|
|
@ -7,6 +7,11 @@ namespace Rhymix\Framework\Drivers\Cache;
|
||||||
*/
|
*/
|
||||||
class Dummy implements \Rhymix\Framework\Drivers\CacheInterface
|
class Dummy implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy data is stored here.
|
* Dummy data is stored here.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/file.php
vendored
5
common/framework/drivers/cache/file.php
vendored
|
|
@ -9,6 +9,11 @@ use Rhymix\Framework\Storage;
|
||||||
*/
|
*/
|
||||||
class File implements \Rhymix\Framework\Drivers\CacheInterface
|
class File implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cache directory.
|
* The cache directory.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/memcached.php
vendored
5
common/framework/drivers/cache/memcached.php
vendored
|
|
@ -7,6 +7,11 @@ namespace Rhymix\Framework\Drivers\Cache;
|
||||||
*/
|
*/
|
||||||
class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Memcached connection is stored here.
|
* The Memcached connection is stored here.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/redis.php
vendored
5
common/framework/drivers/cache/redis.php
vendored
|
|
@ -7,6 +7,11 @@ namespace Rhymix\Framework\Drivers\Cache;
|
||||||
*/
|
*/
|
||||||
class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Redis connection is stored here.
|
* The Redis connection is stored here.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/sqlite.php
vendored
5
common/framework/drivers/cache/sqlite.php
vendored
|
|
@ -9,6 +9,11 @@ use Rhymix\Framework\Storage;
|
||||||
*/
|
*/
|
||||||
class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database handle and prepared statements are stored here.
|
* The database handle and prepared statements are stored here.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/wincache.php
vendored
5
common/framework/drivers/cache/wincache.php
vendored
|
|
@ -7,6 +7,11 @@ namespace Rhymix\Framework\Drivers\Cache;
|
||||||
*/
|
*/
|
||||||
class WinCache implements \Rhymix\Framework\Drivers\CacheInterface
|
class WinCache implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of the current cache driver, using the given settings.
|
* Create a new instance of the current cache driver, using the given settings.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
5
common/framework/drivers/cache/xcache.php
vendored
5
common/framework/drivers/cache/xcache.php
vendored
|
|
@ -7,6 +7,11 @@ namespace Rhymix\Framework\Drivers\Cache;
|
||||||
*/
|
*/
|
||||||
class XCache implements \Rhymix\Framework\Drivers\CacheInterface
|
class XCache implements \Rhymix\Framework\Drivers\CacheInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set this flag to false to disable cache prefixes.
|
||||||
|
*/
|
||||||
|
public $prefix = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of the current cache driver, using the given settings.
|
* Create a new instance of the current cache driver, using the given settings.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,7 @@ class adminAdminView extends admin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$object_cache_type = 'dummy';
|
$object_cache_type = 'file';
|
||||||
}
|
}
|
||||||
$cache_default_ttl = 86400;
|
$cache_default_ttl = 86400;
|
||||||
$cache_servers = Rhymix\Framework\Config::get('cache');
|
$cache_servers = Rhymix\Framework\Config::get('cache');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue