GreedyDatabaseBackend

Read onlyYes

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.

Internal

not part of public API, as this needs to be streamlined and proven

Table of Contents

Properties

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

Methods

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

Properties

Methods

getRows()

public getRows(string $tableName, array<string|int, mixed> $uids, Context $context) : array<string|int, mixed>
Parameters
$tableName : string
$uids : array<string|int, mixed>
$context : Context
Return values
array<string|int, mixed>

createRuntimeCacheIdentifier()

protected createRuntimeCacheIdentifier(string $tableName, array<string|int, mixed> $uids, Context $context[, string $suffix = '' ]) : string
Parameters
$tableName : string
$uids : array<string|int, mixed>
$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<string|int, mixed> $uids, Context $context) : array<string|int, mixed>|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<string|int, mixed>
$context : Context
Return values
array<string|int, mixed>|null

getRowsFromDatabase()

protected getRowsFromDatabase(string $tableName, array<string|int, mixed> $uids, Context $context) : array<string|int, mixed>
Parameters
$tableName : string
$uids : array<string|int, mixed>
$context : Context
Return values
array<string|int, mixed>

handleOverlays()

protected handleOverlays(array<string|int, mixed> $rows, string $dbTable, Context $context) : array<string|int, mixed>
Parameters
$rows : array<string|int, mixed>
$dbTable : string
$context : Context
Return values
array<string|int, mixed>

setCache()

protected setCache(string $cacheIdentifier, string $tableName, Context $context, array<string|int, mixed> $allRows) : void
Parameters
$cacheIdentifier : string
$tableName : string
$context : Context
$allRows : array<string|int, mixed>

        
On this page

Search results