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.

Internal

This class is not part of the TYPO3 Core API

Attributes
#[Autoconfigure]
$public: true

Table of Contents

Properties

$connectionPool  : ConnectionPool
$defaultCacheTimeout  : int
$eventDispatcher  : EventDispatcherInterface
$runtimeCache  : FrontendInterface

Methods

__construct()  : mixed
calculateLifetimeForPage()  : int
Get the cache lifetime in seconds for the given page.
calculatePageCacheLifetime()  : int
Calculates page cache timeout according to the records with starttime/endtime on the page.
getCurrentPageCacheConfiguration()  : array<string|int, mixed>
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.

Properties

$defaultCacheTimeout

protected int $defaultCacheTimeout = 86400

$eventDispatcher read-only

protected EventDispatcherInterface $eventDispatcher

Methods

calculateLifetimeForPage()

Get the cache lifetime in seconds for the given page.

public calculateLifetimeForPage(int $pageId, array<string|int, mixed> $pageRecord, array<string|int, mixed> $renderingInstructions, int $defaultCacheTimoutInSeconds, Context $context) : int
Parameters
$pageId : int
$pageRecord : array<string|int, mixed>
$renderingInstructions : array<string|int, mixed>
$defaultCacheTimoutInSeconds : int
$context : Context
Return values
int

calculatePageCacheLifetime()

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

protected calculatePageCacheLifetime(array<string|int, mixed> $tablesToConsider, int $currentTimestamp) : int
Parameters
$tablesToConsider : array<string|int, mixed>
$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<string|int, mixed> $renderingInstructions) : array<string|int, mixed>

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<string|int, mixed>
Tags
see
calculatePageCacheLifetime()
Return values
array<string|int, mixed>

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

Search results