[TYPO3-core] RFC: #11271: Use 2 level cache for BEgetRootLine

Fabrizio Branca news at _REMOVETHIS_fabrizio-branca.de
Fri Jun 5 15:15:42 CEST 2009


> Can we have a two/three/multi-level cache in t3lib/cache first?

Hi,

I've thought implementing this before and in the attachment you'll find 
my first shot (not tested, only an idea until now) of a "chain backend".

The idea is that this backend is a container for as many "real" backends 
you want in a defined order. When asking the backend he traverses the 
real backend until he finds a cache hit and updates all previous 
backends with this value. When storing something there it will be stored 
in all backend. This behaviour could be made configurable.

The xml2array would then only lok in this chained cache and the rest of 
that two level logic will be performed within the chain cache.

Here is how to setup the chain backend using a globals backend as first 
level cache and reusing the cache_hash backend as second level cache:

$twoLevelCache = $GLOBALS['typo3CacheFactory']->create(
	'twolevel',
	't3lib_cache_frontend_VariableFrontend',
	't3lib_cache_backend_chainbackend'
);
	// create globals cache
$globalsCache = $GLOBALS['typo3CacheFactory']->create(
	'globals',
	't3lib_cache_frontend_VariableFrontend',
	't3lib_cache_backend_GlobalsBackend'
);

$chainBackend = $twoLevelCache->getBackend();
$chainBackend->addBackend($GLOBALS['typo3CacheManager']->getCache('globals')->getBackend());
$chainBackend->addBackend($GLOBALS['typo3CacheManager']->getCache('cache_hash')->getBackend());

Bye,

Fabrizio	



More information about the TYPO3-team-core mailing list