Attached Files |
In-Portal_5.2.0-B3_Broken_Caching-NavBar.png [^] (98,224 bytes) 2012-04-18 11:04

caching_not_working_without_memcache.patch [^] (10,780 bytes) 2012-04-20 06:15
[Show Content]
Index: cache.php
===================================================================
--- cache.php (revision 15226)
+++ cache.php (working copy)
@@ -110,21 +110,21 @@
$handler_class = 'FakeCacheHandler';
}
- $handler = new $handler_class();
+ $handler = new $handler_class($this);
if ( !$handler->isWorking() ) {
// defined cache handler is not working -> use default
trigger_error('Failed to initialize "<strong>' . $handler_class . '</strong>" caching handler.', E_USER_WARNING);
- $handler = new FakeCacheHandler();
+ $handler = new FakeCacheHandler($this);
}
- elseif ( $this->Application->isDebugMode() && ($handler->cachingType == CACHING_TYPE_MEMORY) ) {
+ elseif ( $this->Application->isDebugMode() && ($handler->getCachingType() == CACHING_TYPE_MEMORY) ) {
$this->Application->Debugger->appendHTML('Memory Caching: "<strong>' . $handler_class . '</strong>"');
}
- $this->_handler =& $handler;
- $this->cachingType = $handler->cachingType;
- $this->debugCache = $handler->cachingType == CACHING_TYPE_MEMORY && $this->Application->isDebugMode();
+ $this->_handler = $handler;
+ $this->cachingType = $handler->getCachingType();
+ $this->debugCache = $handler->getCachingType() == CACHING_TYPE_MEMORY && $this->Application->isDebugMode();
$this->_storeStatistics = defined('DBG_CACHE') && DBG_CACHE;
if ( $this->_storeStatistics ) {
@@ -340,6 +340,19 @@
}
/**
+ * Returns cached value from local cache
+ *
+ * @param string $prepared_name Prepared key name from kCache::prepareKeyName() function
+ * @return mixed
+ * @see prepareKeyName
+ * @access public
+ */
+ public function getFromLocalStorage($prepared_name)
+ {
+ return array_key_exists($prepared_name, $this->_localStorage) ? $this->_localStorage[$prepared_name] : false;
+ }
+
+ /**
* Returns value from cache
*
* @param string|Array $names
@@ -545,13 +558,34 @@
}
- class FakeCacheHandler {
+ abstract class kCacheHandler {
- var $cachingType = CACHING_TYPE_TEMPORARY;
+ /**
+ * Remembers status of cache handler (working or not)
+ *
+ * @var bool
+ * @access protected
+ */
+ protected $_enabled = false;
- function FakeCacheHandler()
+ /**
+ * Caching type that caching handler implements
+ *
+ * @var int
+ * @access protected
+ */
+ protected $cachingType;
+
+ /**
+ *
+ * @var kCache
+ * @access protected
+ */
+ protected $parent;
+
+ public function __construct(kCache $parent)
{
-
+ $this->parent = $parent;
}
/**
@@ -559,20 +593,95 @@
*
* @param string $names
* @return mixed
+ * @access public
*/
- function get($names)
+ abstract public function get($names);
+
+ /**
+ * Stores value in cache
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param int $expiration
+ * @return bool
+ * @access public
+ */
+ abstract public function set($name, $value, $expiration = 0);
+
+ /**
+ * Stores value in cache (only if it's not there already)
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param int $expiration
+ * @return bool
+ * @access public
+ */
+ abstract public function add($name, $value, $expiration = 0);
+
+ /**
+ * Deletes key from cach
+ *
+ * @param string $name
+ * @return bool
+ * @access public
+ */
+ abstract public function delete($name);
+
+ /**
+ * Determines, that cache storage is working fine
+ *
+ * @return bool
+ * @access public
+ */
+ public function isWorking()
{
+ return $this->_enabled;
+ }
+
+ /**
+ * Returns caching type of current storage engine
+ *
+ * @return int
+ * @access public
+ */
+ public function getCachingType()
+ {
+ return $this->cachingType;
+ }
+ }
+
+
+ class FakeCacheHandler extends kCacheHandler {
+
+ public function __construct(kCache $parent)
+ {
+ parent::__construct($parent);
+
+ $this->_enabled = true;
+ $this->cachingType = CACHING_TYPE_TEMPORARY;
+ }
+
+ /**
+ * Retrieves value from cache
+ *
+ * @param string|Array $names
+ * @return mixed
+ * @access public
+ */
+ public function get($names)
+ {
if ( is_array($names) ) {
$res = Array ();
foreach ($names as $name) {
- $res[$name] = false;
+ $res[$name] = $this->parent->getFromLocalStorage($name);
}
return $res;
}
- return false;
+ return $this->parent->getFromLocalStorage($names);
}
/**
@@ -582,8 +691,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function set($name, $value, $expiration = 0)
+ public function set($name, $value, $expiration = 0)
{
return true;
}
@@ -595,8 +705,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function add($name, $value, $expiration = 0)
+ public function add($name, $value, $expiration = 0)
{
return true;
}
@@ -606,39 +717,31 @@
*
* @param string $name
* @return bool
+ * @access public
*/
- function delete($name)
+ public function delete($name)
{
return true;
}
-
- /**
- * Determines, that cache storage is working fine
- *
- * @return bool
- */
- function isWorking()
- {
- return true;
- }
}
- class MemcacheCacheHandler {
+ class MemcacheCacheHandler extends kCacheHandler {
- var $_enabled = false;
-
/**
* Memcache connection
*
* @var Memcache
+ * @access protected
*/
- var $_handler = null;
+ protected $_handler = null;
- var $cachingType = CACHING_TYPE_MEMORY;
+ public function __construct(kCache $parent, $default_servers = '')
+ {
+ parent::__construct($parent);
- function MemcacheCacheHandler($default_servers = '')
- {
+ $this->cachingType = CACHING_TYPE_MEMORY;
+
$vars = kUtil::getConfigVars();
$memcached_servers = isset($vars['MemcacheServers']) ? $vars['MemcacheServers'] : $default_servers;
@@ -672,8 +775,9 @@
*
* @param string $name
* @return mixed
+ * @access public
*/
- function get($name)
+ public function get($name)
{
return $this->_handler->get($name);
}
@@ -685,8 +789,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function set($name, $value, $expiration = 0)
+ public function set($name, $value, $expiration = 0)
{
// 0 - don't use compression
return $this->_handler->set($name, $value, 0, $expiration);
@@ -699,8 +804,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function add($name, $value, $expiration = 0)
+ public function add($name, $value, $expiration = 0)
{
// 0 - don't use compression
return $this->_handler->add($name, $value, 0, $expiration);
@@ -711,36 +817,26 @@
*
* @param string $name
* @return bool
+ * @access public
*/
- function delete($name)
+ public function delete($name)
{
return $this->_handler->delete($name, 0);
}
-
- /**
- * Determines, that cache storage is working fine
- *
- * @return bool
- */
- function isWorking()
- {
- return $this->_enabled;
- }
}
- class ApcCacheHandler {
+ class ApcCacheHandler extends kCacheHandler {
- var $_enabled = false;
+ public function __construct(kCache $parent)
+ {
+ parent::__construct($parent);
- var $cachingType = CACHING_TYPE_MEMORY;
-
- function ApcCacheHandler()
- {
+ $this->cachingType = CACHING_TYPE_MEMORY;
$this->_enabled = function_exists('apc_fetch');
- // verify, that apc is working
- if ($this->_enabled && !$this->set('test', 1)) {
+ // verify, that apc is working
+ if ( $this->_enabled && !$this->set('test', 1) ) {
$this->_enabled = false;
}
}
@@ -750,8 +846,9 @@
*
* @param string $name
* @return mixed
+ * @access public
*/
- function get($name)
+ public function get($name)
{
return apc_fetch($name);
}
@@ -763,8 +860,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function set($name, $value, $expiration = 0)
+ public function set($name, $value, $expiration = 0)
{
return apc_store($name, $value, $expiration);
}
@@ -776,8 +874,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function add($name, $value, $expiration = 0)
+ public function add($name, $value, $expiration = 0)
{
return apc_add($name, $value, $expiration);
}
@@ -787,35 +886,26 @@
*
* @param string $name
* @return bool
+ * @access public
*/
- function delete($name)
+ public function delete($name)
{
return apc_delete($name);
}
-
- /**
- * Determines, that cache storage is working fine
- *
- * @return bool
- */
- function isWorking()
- {
- return $this->_enabled;
- }
}
- class XCacheCacheHandler {
- var $_enabled = false;
+ class XCacheCacheHandler extends kCacheHandler {
- var $cachingType = CACHING_TYPE_MEMORY;
+ public function __construct(kCache $parent)
+ {
+ parent::__construct($parent);
- function XCacheCacheHandler()
- {
+ $this->cachingType = CACHING_TYPE_MEMORY;
$this->_enabled = function_exists('xcache_get');
- // verify, that xcache is working
- if ($this->_enabled && !$this->set('test', 1)) {
+ // verify, that xcache is working
+ if ( $this->_enabled && !$this->set('test', 1) ) {
$this->_enabled = false;
}
}
@@ -825,8 +915,9 @@
*
* @param string|Array $names
* @return mixed
+ * @access public
*/
- function get($names)
+ public function get($names)
{
if ( is_array($names) ) {
$res = Array ();
@@ -848,8 +939,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function set($name, $value, $expiration = 0)
+ public function set($name, $value, $expiration = 0)
{
return xcache_set($name, $value, $expiration);
}
@@ -861,8 +953,9 @@
* @param mixed $value
* @param int $expiration
* @return bool
+ * @access public
*/
- function add($name, $value, $expiration = 0)
+ public function add($name, $value, $expiration = 0)
{
// not atomic operation, like in Memcached and may fail
if ( xcache_isset($name) ) {
@@ -877,19 +970,10 @@
*
* @param string $name
* @return bool
+ * @access public
*/
- function delete($name)
+ public function delete($name)
{
return xcache_unset($name);
}
-
- /**
- * Determines, that cache storage is working fine
- *
- * @return bool
- */
- function isWorking()
- {
- return $this->_enabled;
- }
}
\ No newline at end of file
serial_requests_not_cached_locally.patch [^] (610 bytes) 2012-04-20 06:26
[Show Content]
Index: kernel/utility/cache.php
===================================================================
--- kernel/utility/cache.php (revision 15309)
+++ kernel/utility/cache.php (working copy)
@@ -271,7 +271,7 @@
*/
function getCache($name, $store_locally = true, $max_rebuild_seconds = 0)
{
- $cached_data = $this->_getCache(Array ($name . '_rebuild', $name . '_serials'), Array (true, false));
+ $cached_data = $this->_getCache(Array ($name . '_rebuild', $name . '_serials'), Array (true, true));
if ( $cached_data[$name . '_rebuild'] ) {
// cache rebuild requested -> rebuild now
broken_cache_handler_detection_at_install.patch [^] (802 bytes) 2012-05-16 09:13
[Show Content]
Index: install/install_toolkit.php
===================================================================
--- install/install_toolkit.php (revision 15331)
+++ install/install_toolkit.php (working copy)
@@ -1122,6 +1122,8 @@
$current = $this->getSystemConfig('Misc', 'CacheHandler');
}
+ $cache_handler = $this->Application->makeClass('kCache');
+
$cache_handlers = Array (
'Fake' => 'None', 'Memcache' => 'Memcached', 'XCache' => 'XCache', 'Apc' => 'Alternative PHP Cache'
);
@@ -1133,7 +1135,7 @@
unset($cache_handlers[$class_prefix]);
}
else {
- $handler = new $handler_class('localhost:11211');
+ $handler = new $handler_class($cache_handler, 'localhost:11211');
/* @var $handler FakeCacheHandler */
if ( !$handler->isWorking() ) {
|