CacheService

class \TYPO3\CMS\Extbase\Service\CacheService

Implements
SingletonInterface

Cache clearing helper functions

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$cacheTagStack  : SplStack
$clearCacheForTables  : array

Methods

__construct()  : mixed
clearCacheForRecord()  : void
Stores a record into the stack to resolve the page IDs later-on to clear the caches on these pages then.
clearCachesOfRegisteredPageIds()  : void
First, this method checks, if any records are registered (usually via Database Backend) to be analyzed for a page record, if so, adds additional page IDs to the pageIdStack.
clearPageCache()  : void
Clears the page cache
getCacheTagStack()  : SplStack
getPageIdStack()  : SplStack
clearPageCacheForGivenRecord()  : void
Finds the right PID(s) of a given record and loads the TYPO3 page cache for the given record.

Properties

$cacheTagStack

protected SplStack $cacheTagStack

$clearCacheForTables

protected array $clearCacheForTables = []

Methods

clearCacheForRecord()

Stores a record into the stack to resolve the page IDs later-on to clear the caches on these pages then.

public clearCacheForRecord(string $table, int $uid) : void

Make sure to call clearCachesOfRegisteredPageIds() afterwards.

Parameters

$table : string
$uid : int

clearCachesOfRegisteredPageIds()

First, this method checks, if any records are registered (usually via Database Backend) to be analyzed for a page record, if so, adds additional page IDs to the pageIdStack.

public clearCachesOfRegisteredPageIds() : void

Walks through the pageIdStack, collects all pageIds as array and passes them on to clearPageCache.

clearPageCache()

Clears the page cache

public clearPageCache([int|int[] $pageIdsToClear = null ]) : void

Parameters

$pageIdsToClear : int|int[] = null

single or multiple pageIds to clear the cache for

getCacheTagStack()

public getCacheTagStack() : SplStack

Return values

SplStack

getPageIdStack()

public getPageIdStack() : SplStack

Deprecated

since TYPO3 v13, will be removed in TYPO3 v14. Use CacheService->getCacheTagStack() instead. Push cache tags directly instead of page IDs.

Return values

SplStack

clearPageCacheForGivenRecord()

Finds the right PID(s) of a given record and loads the TYPO3 page cache for the given record.

protected clearPageCacheForGivenRecord(string $tableName, int $uid) : void

If the record lies on a page, then we clear the cache of this page. If the record has no PID column, we clear the cache of the current page as best-effort.

Much of this functionality is taken from DataHandler::clear_cache() which unfortunately only works with logged-in BE user.

Parameters

$tableName : string

Table name of the record

$uid : int

UID of the record

On this page