‪TYPO3CMS  11.5
TYPO3\CMS\Extbase\Service\CacheService Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Service\CacheService:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

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

Protected Member Functions

 clearPageCacheForGivenRecord (string $tableName, int $uid)
 
 getTypoScriptFrontendController ()
 

Protected Attributes

array $hasPidColumn = []
 
array $clearCacheForTables = []
 
ConfigurationManagerInterface $configurationManager
 
CacheManager $cacheManager
 
ConnectionPool $connectionPool
 
SplStack $pageIdStack
 

Detailed Description

Cache clearing helper functions

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

Definition at line 34 of file CacheService.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Service\CacheService::__construct ( ConfigurationManagerInterface  $configurationManager,
CacheManager  $cacheManager 
)

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.

Parameters
string$table
int$uid

Definition at line 117 of file CacheService.php.

◆ 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 88 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

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

Definition at line 66 of file CacheService.php.

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

◆ clearPageCacheForGivenRecord()

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

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.

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

Definition at line 135 of file CacheService.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Extbase\Service\CacheService\getPageIdStack(), TYPO3\CMS\Extbase\Service\CacheService\getTypoScriptFrontendController(), 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 ( )

◆ getTypoScriptFrontendController()

TYPO3\CMS\Extbase\Service\CacheService::getTypoScriptFrontendController ( )
protected

Member Data Documentation

◆ $cacheManager

CacheManager TYPO3\CMS\Extbase\Service\CacheService::$cacheManager
protected

Definition at line 44 of file CacheService.php.

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

◆ $clearCacheForTables

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

Definition at line 42 of file CacheService.php.

◆ $configurationManager

ConfigurationManagerInterface TYPO3\CMS\Extbase\Service\CacheService::$configurationManager
protected

Definition at line 43 of file CacheService.php.

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

◆ $connectionPool

ConnectionPool TYPO3\CMS\Extbase\Service\CacheService::$connectionPool
protected

Definition at line 45 of file CacheService.php.

◆ $hasPidColumn

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

As determining the table columns is a costly operation this is done only once per table during runtime and cached then

See also
clearPageCache()

Definition at line 41 of file CacheService.php.

◆ $pageIdStack

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