Issue Bug Closed

#17210Extending caching system (cache_hash)

John Angel 04/14/07, 15:09 updated 05/05/13, 11:17

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)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.