CacheManager
class CacheManager implements Factory mixin Repository mixin LockProvider mixin TaggableStore
Traits
Constants
| protected MEMOIZED_CONTEXT_KEY_PREFIX |
The context key prefix for memoized cache repositories. |
Properties
| protected array | $stores | The array of resolved cache stores. |
|
| protected array | $customCreators | The registered custom driver creators. |
|
| protected SerializableClassPolicy | $serializableClassPolicy | The serializable class policy shared by built-in cache stores. |
Methods
Get a cache store instance by name, wrapped in a repository.
Get a cache driver instance.
Get a memoized cache driver instance.
Create a memoized repository for the given driver.
Resolve the given store.
Build a cache repository with the given configuration.
Call a custom driver creator.
Create an instance of the array cache driver.
Create an instance of the worker-lifetime array cache driver.
Create an instance of the database cache driver.
Create an instance of the failover cache driver.
Create an instance of the file cache driver.
Create an instance of the storage cache driver.
Create an instance of the Null cache driver.
Create an instance of the Redis cache driver.
Create an instance of the session cache driver.
Get the session store implementation.
Create an instance of the Swoole cache driver.
Create an instance of the Stack cache driver.
Create a new cache repository with the given implementation.
Set the event dispatcher on the given repository instance.
Re-set the event dispatcher on all resolved cache repositories.
Get the cache prefix.
Get the cache connection configuration.
Get the default cache driver name.
Set the default cache driver name.
Unset the given driver instances.
Disconnect the given driver and remove from local cache.
Register classes that cache stores may unserialize.
Finalize the worker-lifetime serializable class policy.
Register a callback to be invoked when an unserializable class is encountered.
Dynamically call the default driver instance.
Details
in
RebindsCallbacksToSelf at line 18
protected Closure|null
bindCallbackToSelf(Closure $callback)
Bind the provided callback to the class instance.
at line 61
__construct(Container $app)
Create a new Cache manager instance.
at line 72
Repository
store(UnitEnum|string|null $name = null)
Get a cache store instance by name, wrapped in a repository.
at line 86
Repository
driver(UnitEnum|string|null $driver = null)
Get a cache driver instance.
at line 97
Repository
memo(UnitEnum|string|null $driver = null)
Get a memoized cache driver instance.
The memoized repository is isolated to the current coroutine and resets when the coroutine ends.
at line 117
protected Repository
createMemoizedRepository(string $driver)
Create a memoized repository for the given driver.
at line 138
Repository
resolve(string $name)
Resolve the given store.
at line 156
Repository
build(array $config)
Build a cache repository with the given configuration.
at line 176
protected Repository
callCustomCreator(array $config)
Call a custom driver creator.
at line 184
protected Repository
createArrayDriver(array $config)
Create an instance of the array cache driver.
at line 195
protected Repository
createWorkerArrayDriver(array $config)
Create an instance of the worker-lifetime array cache driver.
at line 206
protected Repository
createDatabaseDriver(array $config)
Create an instance of the database cache driver.
at line 231
protected Repository
createFailoverDriver(array $config)
Create an instance of the failover cache driver.
at line 243
protected Repository
createFileDriver(array $config)
Create an instance of the file cache driver.
at line 260
protected Repository
createStorageDriver(array $config)
Create an instance of the storage cache driver.
at line 273
protected Repository
createNullDriver()
Create an instance of the Null cache driver.
at line 281
protected Repository
createRedisDriver(array $config)
Create an instance of the Redis cache driver.
at line 305
protected Repository
createSessionDriver(array $config)
Create an instance of the session cache driver.
at line 321
protected Session
getSession()
Get the session store implementation.
at line 333
protected Repository
createSwooleDriver(array $config)
Create an instance of the Swoole cache driver.
at line 350
protected Repository
createStackDriver(array $config)
Create an instance of the Stack cache driver.
at line 369
Repository
repository(Store $store, array $config = [])
Create a new cache repository with the given implementation.
at line 381
protected void
setEventDispatcher(Repository $repository)
Set the event dispatcher on the given repository instance.
at line 400
void
refreshEventDispatcher()
Re-set the event dispatcher on all resolved cache repositories.
Boot or tests only. Replaces the dispatcher on every cached repository for the worker lifetime; per-request use races across coroutines. Reached by Event::fake() / Event::fakeFor() to point cached repositories at the fake dispatcher and to restore them afterwards.
at line 408
protected string
getPrefix(array $config)
Get the cache prefix.
at line 419
protected array|null
getConfig(string $name)
Get the cache connection configuration.
at line 431
string
getDefaultDriver()
Get the default cache driver name.
at line 441
void
setDefaultDriver(UnitEnum|string $name)
Set the default cache driver name.
Boot-only. Mutates process-global config; per-request use races across coroutines.
at line 457
CacheManager
forgetDriver(array|UnitEnum|string|null $name = null)
Unset the given driver instances.
Boot or tests only. Mutates the singleton's store cache; concurrent coroutines may already hold a reference to the store and next resolution will rebuild with fresh connections.
at line 481
void
purge(UnitEnum|string|null $name = null)
Disconnect the given driver and remove from local cache.
Boot or tests only. Mutates the singleton's store cache; concurrent coroutines may already hold a reference to the store and next resolution will rebuild with fresh connections.
at line 498
CacheManager
extend(string $driver, Closure $callback)
Register a custom driver creator Closure.
Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent store resolution.
at line 519
CacheManager
setApplication(Container $app)
Set the application instance used by the manager.
Tests only. Swaps the singleton's container reference; per-request use races across coroutines and breaks every concurrent request resolving stores through this manager.
at line 539
CacheManager
allowSerializableClassesUsing(Closure $resolver)
Register classes that cache stores may unserialize.
Boot-only. The resolver contributes to the worker-lifetime cache policy and is evaluated after every provider has booted: at application boot completion in console processes or after configuration reload in each Swoole worker. An earlier cache read evaluates the current contributions without memoizing them.
at line 554
void
finalizeSerializableClasses()
| internal |
Finalize the worker-lifetime serializable class policy.
Boot-only. The policy is frozen for the worker lifetime; later contributions throw and every subsequent unserialize uses the frozen list.
at line 565
void
handleUnserializableClassUsing(callable|null $callback)
Register a callback to be invoked when an unserializable class is encountered.
Boot or tests only. The callback persists for the worker lifetime and affects every subsequent cache read.
at line 573
mixed
__call(string $method, array $parameters)
Dynamically call the default driver instance.