class CacheManager implements Factory mixin Repository mixin LockProvider (View source)

Traits

Properties

protected Application $app

The application instance.

protected array $stores

The array of resolved cache stores.

protected array $customCreators

The registered custom driver creators.

Methods

Closure|null
bindCallbackToSelf(Closure $callback)

Binds the provided callback to the class instance.

__construct(Application $app)

Create a new Cache manager instance.

store(UnitEnum|string|null $name = null)

Get a cache store instance by name, wrapped in a repository.

driver(UnitEnum|string|null $driver = null)

Get a cache driver instance.

memo(UnitEnum|string|null $driver = null)

Get a memoized cache driver instance.

resolve(string $name)

Resolve the given store.

build(array $config)

Build a cache repository with the given configuration.

mixed
callCustomCreator(array $config)

Call a custom driver creator.

createApcDriver(array $config)

Create an instance of the APC cache driver.

createArrayDriver(array $config)

Create an instance of the array cache driver.

createDatabaseDriver(array $config)

Create an instance of the database cache driver.

createDynamodbDriver(array $config)

Create an instance of the DynamoDB cache driver.

DynamoDbClient
newDynamodbClient(array $config)

Create new DynamoDb Client instance.

createFailoverDriver(array $config)

Create an instance of the failover cache driver.

createFileDriver(array $config)

Create an instance of the file cache driver.

createStorageDriver(array $config)

Create an instance of the storage cache driver.

createMemcachedDriver(array $config)

Create an instance of the Memcached cache driver.

createNullDriver()

Create an instance of the Null cache driver.

createRedisDriver(array $config)

Create an instance of the Redis cache driver.

createSessionDriver(array $config)

Create an instance of the session cache driver.

getSession()

Get the session store implementation.

repository(Store $store, array $config = [])

Create a new cache repository with the given implementation.

void
setEventDispatcher(Repository $repository)

Set the event dispatcher on the given repository instance.

void
refreshEventDispatcher()

Re-set the event dispatcher on all resolved cache repositories.

string
getPrefix(array $config)

Get the cache prefix.

array|bool|null
getSerializableClasses(array $config)

Get the classes that should be allowed during unserialization.

array|null
getConfig(string $name)

Get the cache connection configuration.

string
getDefaultDriver()

Get the default cache driver name.

void
setDefaultDriver(UnitEnum|string $name)

Set the default cache driver name.

$this
forgetDriver(array|UnitEnum|string|null $name = null)

Unset the given driver instances.

void
purge(UnitEnum|string|null $name = null)

Disconnect the given driver and remove from local cache.

$this
extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

$this
setApplication(Application $app)

Set the application instance used by the manager.

void
handleUnserializableClassUsing(callable|null $callback)

Register a callback to be invoked when an unserializable class is encountered.

mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

Details

protected Closure|null bindCallbackToSelf(Closure $callback)

Binds the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

__construct(Application $app)

Create a new Cache manager instance.

Parameters

Application $app

Repository store(UnitEnum|string|null $name = null)

Get a cache store instance by name, wrapped in a repository.

Parameters

UnitEnum|string|null $name

Return Value

Repository

Repository driver(UnitEnum|string|null $driver = null)

Get a cache driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

Repository

Repository memo(UnitEnum|string|null $driver = null)

Get a memoized cache driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

Repository

Repository resolve(string $name)

Resolve the given store.

Parameters

string $name

Return Value

Repository

Exceptions

InvalidArgumentException

Repository build(array $config)

Build a cache repository with the given configuration.

Parameters

array $config

Return Value

Repository

Exceptions

InvalidArgumentException

protected mixed callCustomCreator(array $config)

Call a custom driver creator.

Parameters

array $config

Return Value

mixed

protected Repository createApcDriver(array $config)

Create an instance of the APC cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createArrayDriver(array $config)

Create an instance of the array cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createDatabaseDriver(array $config)

Create an instance of the database cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createDynamodbDriver(array $config)

Create an instance of the DynamoDB cache driver.

Parameters

array $config

Return Value

Repository

protected DynamoDbClient newDynamodbClient(array $config)

Create new DynamoDb Client instance.

Parameters

array $config

Return Value

DynamoDbClient

protected Repository createFailoverDriver(array $config)

Create an instance of the failover cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createFileDriver(array $config)

Create an instance of the file cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createStorageDriver(array $config)

Create an instance of the storage cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createMemcachedDriver(array $config)

Create an instance of the Memcached cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createNullDriver()

Create an instance of the Null cache driver.

Return Value

Repository

protected Repository createRedisDriver(array $config)

Create an instance of the Redis cache driver.

Parameters

array $config

Return Value

Repository

protected Repository createSessionDriver(array $config)

Create an instance of the session cache driver.

Parameters

array $config

Return Value

Repository

protected Session getSession()

Get the session store implementation.

Return Value

Session

Exceptions

InvalidArgumentException

Repository repository(Store $store, array $config = [])

Create a new cache repository with the given implementation.

Parameters

Store $store
array $config

Return Value

Repository

protected void setEventDispatcher(Repository $repository)

Set the event dispatcher on the given repository instance.

Parameters

Repository $repository

Return Value

void

void refreshEventDispatcher()

Re-set the event dispatcher on all resolved cache repositories.

Return Value

void

protected string getPrefix(array $config)

Get the cache prefix.

Parameters

array $config

Return Value

string

protected array|bool|null getSerializableClasses(array $config)

Get the classes that should be allowed during unserialization.

Parameters

array $config

Return Value

array|bool|null

protected array|null getConfig(string $name)

Get the cache connection configuration.

Parameters

string $name

Return Value

array|null

string getDefaultDriver()

Get the default cache driver name.

Return Value

string

void setDefaultDriver(UnitEnum|string $name)

Set the default cache driver name.

Parameters

UnitEnum|string $name

Return Value

void

$this forgetDriver(array|UnitEnum|string|null $name = null)

Unset the given driver instances.

Parameters

array|UnitEnum|string|null $name

Return Value

$this

void purge(UnitEnum|string|null $name = null)

Disconnect the given driver and remove from local cache.

Parameters

UnitEnum|string|null $name

Return Value

void

$this extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Parameters

string $driver
Closure $callback

Return Value

$this

$this setApplication(Application $app)

Set the application instance used by the manager.

Parameters

Application $app

Return Value

$this

void handleUnserializableClassUsing(callable|null $callback)

Register a callback to be invoked when an unserializable class is encountered.

Parameters

callable|null $callback

Return Value

void

mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.