GreedyDatabaseBackend

readonly class \TYPO3\CMS\Core\Domain\Persistence\GreedyDatabaseBackend

Fetches all records of a single table of one / multiple PID(s) in one DB query, and stores them in a runtime cache.

The records are neither grouped nor do we care about

  • sorting
  • limit / offset
  • or BE User permissions.

It is "greedy" because it is meant to do simple query in a fast way, to reduce overlays on a "per record" basis.

The records are fetched depending on

  • fe_group permissions
  • language (incl. overlays etc)
  • workspace
  • visibility restrictions (starttime / endtime / hidden / deleted)

The class returns an array and does not handle objects, as it is very "lowlevel" and thus: internal.

Table of Contents

Properties

$connectionPool  : ConnectionPool
$recordAccessVoter  : RecordAccessVoter
$runtimeCache  : FrontendInterface

Methods

__construct()  : mixed
getRows()  : array
createRuntimeCacheIdentifier()  : string
getRowsFromCache()  : array|null
This method creates cache identifier pointers for each provided uid.
getRowsFromDatabase()  : array
handleOverlays()  : array
setCache()  : void

Properties

Methods

getRows()

public getRows(string $tableName, array $uids, Context $context) : array

Parameters

$tableName : string
$uids : array
$context : Context

Return values

array

createRuntimeCacheIdentifier()

protected createRuntimeCacheIdentifier(string $tableName, array $uids, Context $context[, string $suffix = '' ]) : string

Parameters

$tableName : string
$uids : array
$context : Context
$suffix : string = ''

Return values

string

getRowsFromCache()

This method creates cache identifier pointers for each provided uid.

protected getRowsFromCache(string $cacheIdentifier, string $tableName, array $uids, Context $context) : array|null

These uids come from the same pid, so they will have the same result set. If at a later point in time one of these uids is requested again, the pointer will be used to retrieve the actual cache entry of the db row. Without this mechanism, the runtime cache would be filled quickly with the same database rows over and over again.

Example: Having 1000 records on the same pid with each having a relation to a file reference. When RecordFactory is used to resolve all of these 1000 records at a time, each of these 1000 relations would produce a cache entry with 1000 file reference database rows (1000*1000 = 1.000.000 database rows).

Instead, only 1 cache entry is created with 1000 database rows and in addition 1000 lightweight cache identifier pointers, pointing to the actual value of the cache identifier.

Parameters

$cacheIdentifier : string
$tableName : string
$uids : array
$context : Context

Return values

array|null

getRowsFromDatabase()

protected getRowsFromDatabase(string $tableName, array $uids, Context $context) : array

Parameters

$tableName : string
$uids : array
$context : Context

Return values

array

handleOverlays()

protected handleOverlays(array $rows, string $dbTable, Context $context) : array

Parameters

$rows : array
$dbTable : string
$context : Context

Return values

array

setCache()

protected setCache(string $cacheIdentifier, string $tableName, Context $context, array $allRows) : void

Parameters

$cacheIdentifier : string
$tableName : string
$context : Context
$allRows : array
On this page