Search…
Cache Config Reference
The cache config is located at app/config/cache.php. These options control the application cache.

cache_driver

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

cache_lifetime

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

cache_lottery

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

memcached_host

The Memcached server hostname or IP address.
Possible Values
Default Value
Environment Variable
Any string
localhost
MEMCACHED_HOST

memcached_port

The Memcached server port.
Possible Values
Default Value
Environment Variable
Any valid port as an integer (0 to 65353)
11211
MEMCACHED_PORT

memcached_config

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.
Reference the PHP Memcached documentation for Memcached configuration options.
Possible Values
Default Value
Environment Variables
An anonymous function that receives a Memcached object
1
function (Memcached $memcached): void {
2
// Configure the $memcached object
3
}
Copied!
1
DI\value(function (Memcached $memcached, Config $config): void {
2
$memcached->addServer(
3
$config->get('memcached_host'),
4
$config->get('memcached_port')
5
);
6
})
Copied!
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 default

redis_host

The Redis server hostname or IP address.
Possible Values
Default Value
Environment Variable
Any string
localhost
REDIS_HOST

redis_port

The Redis server port.
Possible Values
Defualt Value
Environment Variable
Any valid port as an integer (0 to 65353)
6379
REDIS_PORT

redis_config

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.
Reference the phpredis documentation for Redis configuration options.
Possible Values
Default Value
Environment Variables
An anonymous function that receives a Redis object
1
function (Redis $redis): void {
2
// Configure the $redis object
3
}
Copied!
1
DI\value(function (Redis $redis, Config $config): void {
2
$redis->pconnect(
3
$config->get('redis_host'),
4
$config->get('redis_port')
5
);
6
})
Copied!
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 default

http_cache

HTTP cache values for controlling browser page cache durations. An array of mimetypes mapped to their cache duration in seconds..
Possible Values
Defualt Value
An array of mime types mapped to their cache duration as a seconds (integers).
1
[
2
'application/json' => 300,
3
'application/zip' => 300,
4
]
Copied!

view_cache

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 entirely
app/cache/views
VIEW_CACHE
Last modified 5mo ago