cacheCollection.php
Table of Contents
Functions
- cacheCollection() : SimpleCache|null
- Creates a namespaced cache collection from a Key/Value store definition registered in the dependency injection container.
Functions
cacheCollection()
Creates a namespaced cache collection from a Key/Value store definition registered in the dependency injection container.
cacheCollection(Container $container, string $collection, string $definition) : SimpleCache|null
A cache collection is an isolated namespace within the same backend, allowing logical separation of cached values (e.g. per feature, domain, or module). This helper function retrieves a KeyValueStore from the container, and wraps its collection in a PSR-16 SimpleCache implementation.
It returns null when the definition is not registered in the container, or
when the resolved entry is not a KeyValueStore — making it safe to use
as an optional cache layer.
Parameters
- $container : Container
-
The DI container used to resolve the cache store definition.
- $collection : string
-
The collection name (namespace) to create inside the cache store.
- $definition : string
-
The container entry identifier of the base key/value store in the DI container.
Tags
Return values
SimpleCache|null —A PSR-16 cache instance scoped to the given collection, or null if the definition is not found or not compatible.