class FirstLevelNodeCache (View source)

A first level cache for the NodeDataRepository. It is used to keep Nodes in memory (indexed by identifier and path) and allows to fetch them by path or identifier as single node.

The caching of multiple nodes below a certain path is possible as well, using the *ChildNodesByPathAndNodeTypeFilter() methods.

Properties

protected NodeInterface[] $nodesByPath
protected NodeInterface[] $nodesByIdentifier
protected NodeInterface[] $childNodesByPathAndNodeTypeFilter

Methods

getByPath(string $path)

If the cache contains a node for the given path, it is returned.

void
setByPath(string $path, NodeInterface $node = null)

Adds the given node to the cache for the given path. The node will also be added under it's identifier.

getByIdentifier(string $identifier)

If the cache contains a node with the given identifier, it is returned.

void
setByIdentifier(string $identifier, NodeInterface $node = null)

Adds the given node to the cache for the given identifier. The node will also be added with is's path.

removeNodeFromIdentifierCache(string $identifier)

Removes the Node with identifier $identifier from the cache.

removeNodeFromPathCache(string $nodePath)

Removes the Node Path $nodePath from the cache.

bool
getChildNodesByPathAndNodeTypeFilter(string $path, string $nodeTypeFilter)

Returns the cached child nodes for the given path and node type filter.

void
setChildNodesByPathAndNodeTypeFilter(string $path, string $nodeTypeFilter, array $nodes)

Sets the given nodes as child nodes for the given path and node type filter.

void
flush()

Flush the cache.

Details

NodeInterface|bool getByPath(string $path)

If the cache contains a node for the given path, it is returned.

Otherwise false is returned.

Parameters

string $path

Return Value

NodeInterface|bool

void setByPath(string $path, NodeInterface $node = null)

Adds the given node to the cache for the given path. The node will also be added under it's identifier.

Parameters

string $path
NodeInterface $node

Return Value

void

NodeInterface|bool getByIdentifier(string $identifier)

If the cache contains a node with the given identifier, it is returned.

Otherwise false is returned.

Parameters

string $identifier

Return Value

NodeInterface|bool

void setByIdentifier(string $identifier, NodeInterface $node = null)

Adds the given node to the cache for the given identifier. The node will also be added with is's path.

Parameters

string $identifier
NodeInterface $node

Return Value

void

removeNodeFromIdentifierCache(string $identifier)

Removes the Node with identifier $identifier from the cache.

This is needed in extremely rare cases: When loading Nodes in the Security Framework, we need to ensure we do not pollute the Node cache, as otherwise these nodes will be found lateron when the actual queries are made.

Parameters

string $identifier

removeNodeFromPathCache(string $nodePath)

Removes the Node Path $nodePath from the cache.

This is needed in extremely rare cases: When loading Nodes in the Security Framework, we need to ensure we do not pollute the Node cache, as otherwise these nodes will be found lateron when the actual queries are made.

Parameters

string $nodePath

bool getChildNodesByPathAndNodeTypeFilter(string $path, string $nodeTypeFilter)

Returns the cached child nodes for the given path and node type filter.

Parameters

string $path
string $nodeTypeFilter

Return Value

bool

void setChildNodesByPathAndNodeTypeFilter(string $path, string $nodeTypeFilter, array $nodes)

Sets the given nodes as child nodes for the given path and node type filter.

The nodes will each be added with their path and identifier as well.

Parameters

string $path
string $nodeTypeFilter
array $nodes

Return Value

void

void flush()

Flush the cache.

Return Value

void