‪TYPO3CMS  ‪main
TYPO3\CMS\Extbase\Service\CacheService Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Service\CacheService:

Public Member Functions

 __construct (private readonly ConfigurationManagerInterface $configurationManager, private readonly CacheManager $cacheManager, private readonly ConnectionPool $connectionPool,)
 getPageIdStack ()
 clearPageCache ($pageIdsToClear=null)
 clearCachesOfRegisteredPageIds ()
 clearCacheForRecord (string $table, int $uid)

Protected Member Functions

 clearPageCacheForGivenRecord (string $tableName, int $uid)

Protected Attributes

array $clearCacheForTables = []
SplStack $pageIdStack

Detailed Description

Cache clearing helper functions

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 33 of file CacheService.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Service\CacheService::__construct ( private readonly ConfigurationManagerInterface  $configurationManager,
private readonly CacheManager  $cacheManager,
private readonly ConnectionPool  $connectionPool 

Definition at line 38 of file CacheService.php.

Member Function Documentation

◆ clearCacheForRecord()

TYPO3\CMS\Extbase\Service\CacheService::clearCacheForRecord ( string  $table,
int  $uid 

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

Make sure to call clearCachesOfRegisteredPageIds() afterwards.


Definition at line 105 of file CacheService.php.

References TYPO3\CMS\Webhooks\Message\$uid.

◆ clearCachesOfRegisteredPageIds()

TYPO3\CMS\Extbase\Service\CacheService::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.

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

Definition at line 76 of file CacheService.php.

References TYPO3\CMS\Extbase\Service\CacheService\clearPageCache(), TYPO3\CMS\Extbase\Service\CacheService\clearPageCacheForGivenRecord(), and TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK.

◆ clearPageCache()

TYPO3\CMS\Extbase\Service\CacheService::clearPageCache (   $pageIdsToClear = null)

Clears the page cache

int | int[]$pageIdsToClear‪single or multiple pageIds to clear the cache for

Definition at line 56 of file CacheService.php.

Referenced by TYPO3\CMS\Extbase\Service\CacheService\clearCachesOfRegisteredPageIds().

◆ clearPageCacheForGivenRecord()

TYPO3\CMS\Extbase\Service\CacheService::clearPageCacheForGivenRecord ( string  $tableName,
int  $uid 

Finds the right PID(s) of a given record and loads the TYPO3 page cache for the given record. 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.

string$tableName‪Table name of the record
int$uid‪UID of the record

Definition at line 123 of file CacheService.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Extbase\Service\CacheService\getPageIdStack(), TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Extbase\Service\CacheService\clearCachesOfRegisteredPageIds().

◆ getPageIdStack()

TYPO3\CMS\Extbase\Service\CacheService::getPageIdStack ( )

Member Data Documentation

◆ $clearCacheForTables

array TYPO3\CMS\Extbase\Service\CacheService::$clearCacheForTables = []

Definition at line 35 of file CacheService.php.

◆ $pageIdStack

SplStack TYPO3\CMS\Extbase\Service\CacheService::$pageIdStack