[TYPO3-dev] Clearing the cache of a single instance of a page (single view) instead of the whole page

Krystian Szymukowicz t33k.RE.MO.VE at RE.MO.VE.prolabium.com
Mon Oct 19 09:10:10 CEST 2009


Steffen Müller wrote:
> Hi.
> 
> On 15.10.2009 11:42 Ernesto Baschny [cron IT] wrote:
>> in the new caching framework (starting with 4.3), tt_news could "tag"
>> his single views with certain key e.g. (tt_news:<uid>) and then hook
>> into the processdatamap of TCEmain to delete these cache entries when a
>> tt_news record is modified.
>>
> 
> I just read through the classes t3lib_TCEmain and tslib_fe and the
> caching framework interface. This is the result of my exploration:
> 
> 1) When using the caching framework, tslib_fe also supports reg1. The
> reg1 value (integer) is used as a tag of the cache entry.
> 
> For example this can be used by
> $GLOBALS['TSFE']->page_cache_reg1 = $this->piVars['tt_news']; // Example
> GETvar: &tx_ttnews[tt_news]=123
> 
> Without caching framework:
> field reg1=123 in table cache_pages
> 
> With caching framework:
> cache entry has tag: reg1_123
> 
> This preserves backward compatibility.
> 
> 
> 2) When using the caching framework, tslib_fe allows to add tags to
> $this->pageCacheTags by using $this->addCacheTags(array $tags)
> 
> That means one can use
> $GLOBALS['TSFE']->addCacheTags(array('tx_ttnews_' .
> $this->piVars['tt_news']); // Example GETvar: &tx_ttnews[tt_news]=123
> 
> The result is an additional tag in the cache entry: tx_ttnews_123
> 
> 
> 3) The t3lib_TCEmain API does not (yet) support clearing cache entries
> by tag. But it could be enhanced with a function clear_cache_by_tags()
> 
> public function clear_cache_by_tags(array $tags=array()) {
>   if (TYPO3_UseCachingFramework) {
>     $pageCache = $GLOBALS['typo3CacheManager']->getCache(
>       'cache_pages'
>     );
>     $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache(
>       'cache_pagesection'
>     );
>     $pageCache->flushByTags($tags);
>     $pageSectionCache->flushByTags($tags);
>     }
>   }
> }
> 
> 4) Hooking into processdatamap could then call clear_cache_by_tags() to
> flush the appropriate cache entries.
> 
> What do you think?
> 


Sounds good.

Dan Osipov begun to make something like this. Just look here:
http://forge.typo3.org/projects/show/extension-ttnewscache_cleartag


--
grtz
Krystian Szymukowicz




More information about the TYPO3-dev mailing list