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
Possible Values

apcu, array, file, memcached, redis, php-file

Default Value

file

Environment Variable

CACHE_DRIVER

cache_lifetime

The app cache lifetime (in seconds). Setting this value to 0 will cache indefinitely.

Possible values
Default Value
Environment Variable
Possible values

Any positive integer

Default Value

0 (indefinitely)

Environment Variable

CACHE_LIFETIME

memcached_host

The Memcached server hostname or IP address.

Possible Values
Default Value
Environment Variable
Possible Values

Any string

Default Value

localhost

Environment Variable

MEMCACHED_HOST

memcached_port

The Memcached server port.

Possible Values
Default Value
Environment Variable
Possible Values

Any valid port as an integer (0 to 65353)

Default Value

11211

Environment Variable

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
Possible Values

An anonymous function that receives a Memcached object

function (Memcached $memcached): void {
// Configure the $memcached object
}
Default Value
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.

Environment Variables

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
Possible Values

Any string

Default Value

localhost

Environment Variable

REDIS_HOST

redis_port

The Redis server port.

Possible Values
Defualt Value
Environment Variable
Possible Values

Any valid port as an integer (0 to 65353)

Defualt Value

6379

Environment Variable

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
Possible Values

An anonymous function that receives a Redis object

function (Redis $redis): void {
// Configure the $redis object
}
Default Value
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.

Environment Variables

Uses the REDIS_HOST and REDIS_PORT variables by default

http_expires

HTTP expires values. An array of mimetypes mapped to their cache duration values.

Possible Values
Defualt Value
Possible Values

An array of mime types mapped to their cache duration as a relative datetime string.

Defualt Value
[
'application/zip' => '+1 hour',
'text/json' => '+1 hour',
]

view_cache

Path to the view cache directory. Set to false to disable view caching entirely.

Possible Values
Default Value
Environment Variable
Possible Values

A directory path as a string or false to disable the view cache entirely

Default Value

app/cache/views

Environment Variable

VIEW_CACHE