Kajona\System\System\CacheManager

Cache manager which can store and retrieve values from different cache systems. The API is compatible to the ApcCache but it is possible to specifiy different cache systems.

<code>
$strData = CacheManager::getInstance()->getValue('[key]');

if ($strData !== false) {
return $strData;
} else {
$strData = complexTask();

CacheManager::getInstance()->addValue('[key]', $strData);
}
</code>

It is also possible to specify specific cache types. I.e. if you want to store your data per APC and also on the
filesystem. In this case the system checks first whether an entry is available in APC and then the database
<code>
$objCache = CacheManager::getInstance()->getCache(CacheManager::TYPE_APC | CacheManager::TYPE_DATABASE);
</code>

Synopsis

class CacheManager {
  • // constants
  • const TYPE_ARRAY = 1;
  • const TYPE_APC = 2;
  • const TYPE_DATABASE = 4;
  • const TYPE_FILESYSTEM = 8;
  • const TYPE_PHPFILE = 16;
  • const NS_GLOBAL = 'global';
  • const NS_BOOTSTRAP = 'bootstrap';
}

Constants

Name Value
TYPE_ARRAY 1
TYPE_APC 2
TYPE_DATABASE 4
TYPE_FILESYSTEM 8
TYPE_PHPFILE 16
NS_GLOBAL 'global'
NS_BOOTSTRAP 'bootstrap'

Members

private

protected

  • $arrSystems — array
  • $strSystemKey — string

Methods

protected

public

  • __construct()
  • addValue()
  • flushAll() — Removes the complete cache for a specific type. This actually deletes the data thus the method should be used carefully
  • flushCache() — Flushes the complete cache for the given namespace. Note in most cases that does not delete the actual data instead an internal version number is increased which is always appended to the cache key
  • getAvailableDriver() — Returns all available drivers which can be deleted through the system task
  • getInstance()
  • getStats() — Returns stats informations for a specific type
  • getValue()
  • removeValue()