RecordIdentityMap
The identity map for records is a database access design pattern used to improve performance by providing a context-specific, in-memory cache to prevent duplicate retrieval of the same object data from the database.
In TYPO3 Context, an instance of the RecordIdentityMap is also shared in Frontend (e.g. RecordFactory) and Backend (Page Module) to know which records have been created already.
For this reason, the identity map is shared, but needs to be explicitly shared, and is thus, NOT, marked as a singleton.
Why? Since we deal with "overlays", we also need to keep track of
- Language (Chain)
- Workspace
In TYPO3 Context, the identity map is especially important to avoid infinite recursions when resolving relations in records but allows to re-use existing objects used by this map.
The purpose for the Identity Map for Records is currently only for reading record objects within one records (not writing, and not shared between requests).
not part of TYPO3 Core API as it is used on a low-level basis to keep state of created record objects.
Table of Contents
Properties
- $recordMap : array<int|string, RecordInterface>
Methods
- add() : void
- findByIdentifier() : RecordInterface
- has() : bool
- hasIdentifier() : bool
Properties
$recordMap
protected
array<int|string, RecordInterface>
$recordMap
= []
Methods
add()
public
add(RecordInterface $record) : void
Parameters
- $record : RecordInterface
findByIdentifier()
public
findByIdentifier(string $mainType, int $identifier) : RecordInterface
Parameters
- $mainType : string
- $identifier : int
Return values
RecordInterfacehas()
public
has(RecordInterface $record) : bool
Parameters
- $record : RecordInterface
Return values
boolhasIdentifier()
public
hasIdentifier(string $mainType, int $identifier) : bool
Parameters
- $mainType : string
- $identifier : int