Level 75
You need to work with Cachefacade instead of Redis when you want to work with cache
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to learn Redis by testing it.
I created a custom function in my routes:
Route::get('/', function () {
// redis has posts.all key exists
// posts found then it will return all post without touching the database
if ($roles = Redis::get('role.all')) {
return json_decode($roles);
}
// get all post
$posts = Role::all();
// store into redis
Redis::set('role.all', $roles);
// return all posts
return $roles;
});
I run that once and after that, I delete all the roles from the DB but REDIS still showing the saved values from Database. I cleared the cache from chrome, I run cache:clear and config:cache in artisan, but nothing happens. Redis continue to show me the values.
In my .env the driver is CACHE_DRIVER=redis
and in my cache.php the default driver is 'default' => env('CACHE_DRIVER', 'redis')
How can I clear my Redis cache?
Please or to participate in this conversation.