CacheLifetimeCalculator

class \TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator

Calculates the max lifetime the given page should be stored in TYPO3's page cache.

The "lifetime" is the number of seconds from the current time, it is not a full time/timestamp Example: If the lifetime is "3600" (=1h), the page will be cached for 1h.

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Constants

defaultCacheTimeout  : mixed = 365 * 86400

Properties

$connectionPool  : ConnectionPool
$context  : Context
$eventDispatcher  : EventDispatcherInterface
$runtimeCache  : FrontendInterface
$tcaSchemaFactory  : TcaSchemaFactory

Methods

__construct()  : mixed
calculateLifetimeForPage()  : int
Get the cache lifetime in seconds for the given page.
calculateLifetimeForRow()  : int
Get the cache lifetime in seconds for the given record.
calculatePageCacheLifetime()  : int
Calculates page cache timeout according to the records with starttime/endtime on the page.
getCurrentPageCacheConfiguration()  : array
Obtains a list of table/pid pairs to consider for page caching.
getFirstTimeValueForRecord()  : int
Find the minimum starttime or endtime value in the table and pid that is greater than the current time.

Constants

defaultCacheTimeout

protected mixed defaultCacheTimeout = 365 * 86400

Properties

$eventDispatcher read-only

protected EventDispatcherInterface $eventDispatcher

Methods

calculateLifetimeForPage()

Get the cache lifetime in seconds for the given page.

public calculateLifetimeForPage(int $pageId, array $pageRecord, array $renderingInstructions, Context $context) : int

Parameters

$pageId : int
$pageRecord : array
$renderingInstructions : array
$context : Context

Return values

int

calculateLifetimeForRow()

Get the cache lifetime in seconds for the given record.

public calculateLifetimeForRow(string $tableName, array $record[, int $defaultCacheTimeoutInSeconds = 0 ]) : int

Parameters

$tableName : string
$record : array
$defaultCacheTimeoutInSeconds : int = 0

Return values

int

calculatePageCacheLifetime()

Calculates page cache timeout according to the records with starttime/endtime on the page.

protected calculatePageCacheLifetime(array $tablesToConsider, int $currentTimestamp) : int

Parameters

$tablesToConsider : array
$currentTimestamp : int

Return values

int —

Page cache timeout or PHP_INT_MAX if the timeout cannot be determined

getCurrentPageCacheConfiguration()

Obtains a list of table/pid pairs to consider for page caching.

protected getCurrentPageCacheConfiguration(int $currentPageId, array $renderingInstructions) : array

TS configuration looks like this:

The cache lifetime of all pages takes starttime and endtime of news records of page 14 into account: config.cache.all = tt_news:14

The cache lifetime of the current page allows to take records (e.g. fe_users) into account: config.cache.all = fe_users:current

The cache lifetime of page 42 takes starttime and endtime of news records of page 15 and addresses of page 16 into account: config.cache.42 = tt_news:15,tt_address:16

Parameters

$currentPageId : int
$renderingInstructions : array

Tags

see
calculatePageCacheLifetime()

Return values

array —

Array of 'tablename:pid' pairs. There is at least a current page id in the array

getFirstTimeValueForRecord()

Find the minimum starttime or endtime value in the table and pid that is greater than the current time.

protected getFirstTimeValueForRecord(string $tableDef, int $currentTimestamp) : int

Parameters

$tableDef : string

Table definition (format tablename:pid)

$currentTimestamp : int

the UNIX timestamp of the current time

Tags

throws
InvalidArgumentException
see
calculatePageCacheLifetime()

Return values

int —

Value of the next start/stop time or PHP_INT_MAX if not found

On this page