Laravel provides a unified API for various caching systems. The cache configuration is located in the .env
file. In this file you may specify which cache driver you would like used by default throughout your application. Laravel supports popular caching backends like Memcached and Redis out of the box.
The Lumen cache drivers utilize the exact same code as the full Laravel cache drivers. Beyond configuration, there are no differences between using the cache in Lumen and using the cache in Laravel; therefore, please consult the full Laravel documentation for usage examples.
Note: Before using the
Cache
facade, be sure you have uncommented the$app->withFacades()
method call in yourbootstrap/app.php
file.
Before using a Redis cache with Lumen, you will need to install the illuminate/redis
package via Composer. Then, you should register the Illuminate\Redis\RedisServiceProvider
in your bootstrap/app.php
file:
$app->register(Illuminate\Redis\RedisServiceProvider::class);
If you have not called $app->withEloquent()
in your bootstrap/app.php
file, then you should call $app->configure('database');
in the bootstrap/app.php
file to ensure the Redis database configuration is properly loaded.