Bug #17210
closedExtending caching system (cache_hash)
0%
Description
Benefits: removing garbage entries from cache_hash; better caching system for extensions.
We should introduce two new fields in table cache_hash:
- parent table
- record id of parent table
These fields describe the parent record which the cache entry is related to:
ALTER TABLE `cache_hash` ADD `parent_table` VARCHAR NOT NULL AFTER `hash`;
ALTER TABLE `cache_hash` ADD `parent_table_uid` INT UNSIGNED NOT NULL AFTER `parent_table` ;
ALTER TABLE `cache_hash` ADD INDEX `parent` ( `parent_table` , `parent_table_uid` );
In class.t3lib_page.php:
function storeHash($hash,$data,$ident) {
$insertFields = array(
'hash' => $hash,
'content' => $data,
becomes:
function storeHash($hash,$data,$ident,$parent_table='',$parent_table_uid='') {
$insertFields = array(
'hash' => $hash,
'parent_table' => $parent_table,
'parent_table_uid' => $parent_table_uid,
'content' => $data,
Then, we add the following code in class.t3lib_tcemain.php:5968 (Before "Delete cache for selected pages")
if(!$_params['pageIdArray']) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash',"parent_table='" . $_params['table'] . "'");
}
elseif(is_array($_params['pageIdArray'])) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash',"parent_table='" . $_params['table'] . "' AND parent_table_uid IN (" . implode(",", $_params['pageIdArray']) . ")");
}
else {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash',"parent_table='" . $_params['table'] . "' AND parent_table_uid=" . $_params['pageIdArray']);
}
Then we should change all calls to storeHash function by adding two parameters containing parent information.
E.g.
class.tslib_menu.php:842
$this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA');
becomes:
$this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA', 'pages', $this->id);
Warning: not all menu entries are related to 'pages' table. This was just an example how it can be used.
(issue imported from #M5425)
Files
Updated by John Angel over 17 years ago
After implementing the code above, I've noticed huge number of duplicate 'content' entries for MENUDATA, having the same parent_table and parent_table_uid, but different 'hash' value.
It seems that hash value is taking into account unnecessary values, making these duplicates (class.tslib_menu.php):
$this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array));
For the start, it seems that "serialize($this->tmpl->rootLine)" part should be changed to "serialize($this->id)".
Updated by John Angel over 17 years ago
After careful analyses, I've concluded that current md5 generation of $this->hash value cannot be changed.
Anyway, garbage collector code presented above should be implemented, since cache_hash tends to grow very fast.
Updated by John Angel over 17 years ago
I've submitted the patch.
Probably some parts of find_parent_pages() function can use getRootLine() function.
Updated by Alexander Opitz over 11 years ago
- Category deleted (
Communication) - Status changed from New to Closed
- Target version deleted (
0)
With the Caching Framework a complete new caching system was introduced, so I will close this issue.