Cache Config Reference
The cache config is located at
app/config/cache.php
. These options control the application cache.The application cache driver. Setting this value to
array
will disable the cache across requests. Additional driver-specific options may be required with certain values.Possible Values
Default Value
Environment Variable
apcu
, array
, file
, memcached
, redis
, php-file
file
CACHE_DRIVER
The app cache lifetime (in seconds). Setting this value to
0
will cache indefinitely.Possible values
Default Value
Environment Variable
Any positive integer
60
(one hour)CACHE_LIFETIME
Some cache drivers require manually pruning the cache periodically to remove expired items. This is the percentage chance (out of 100) of a request "winning" the lottery causing the cache to be pruned.
Possible Values
Default Value
Environment Variable
Any integer betweeen
1
and 100
2
CACHE_LOTTERY
The Memcached server hostname or IP address.
Possible Values
Default Value
Environment Variable
Any string
localhost
MEMCACHED_HOST
The Memcached server port.
Possible Values
Default Value
Environment Variable
Any valid port as an integer (
0
to 65353
)11211
MEMCACHED_PORT
The Memcached configuration anonymous function (closure). This option is used when the
cache_driver
configuration option is set to memcached
. The closure receives a Memcached
object as it's only parameter. You can use this object to configure the Memcached connection. At a minimum you must connect to one or more Memcached servers via the addServer()
or addServers()
methods.Possible Values
Default Value
Environment Variables
An anonymous function that receives a
Memcached
objectfunction (Memcached $memcached): void {
// Configure the $memcached object
}
DI\value(function (Memcached $memcached, Config $config): void {
$memcached->addServer(
$config->get('memcached_host'),
$config->get('memcached_port')
);
})
This closure adds a single connection to a server at the host defined by
memcached_host
on the port defined by memcached_port
.Uses the
MEMCACHED_HOST
and MEMCACHED_PORT
variables by defaultThe Redis server hostname or IP address.
Possible Values
Default Value
Environment Variable
Any string
localhost
REDIS_HOST
The Redis server port.
Possible Values
Defualt Value
Environment Variable
Any valid port as an integer (
0
to 65353
)6379
REDIS_PORT
The Redis configuration anonymous function (closure). This option is used when the
cache_driver
configuration option is set to redis
. The closure receives a Redis
object as it's only parameter. You can use this object to configure the Redis connection. At a minimum you must connect to one or more Redis servers via the connect()
or pconnect()
methods.Possible Values
Default Value
Environment Variables
An anonymous function that receives a
Redis
objectfunction (Redis $redis): void {
// Configure the $redis object
}
DI\value(function (Redis $redis, Config $config): void {
$redis->pconnect(
$config->get('redis_host'),
$config->get('redis_port')
);
})
This closure adds a single connection to a server at the host defined by
redis_host
on the port defined by redis_port
.Uses the
REDIS_HOST
and REDIS_PORT
variables by defaultHTTP cache values for controlling browser page cache durations. An array of mimetypes mapped to their cache duration in seconds..
Possible Values
Defualt Value
[
'application/json' => 300,
'application/zip' => 300,
]
Path to the view cache directory. Set to
false
to disable view caching entirely.Possible Values
Default Value
Environment Variable
A directory path as a string or
false
to disable the view cache entirelyapp/cache/views
VIEW_CACHE
Last modified 2yr ago