Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Solvando's avatar

Clearing Redis cache with cache:clear

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?

0 likes
1 reply

Please or to participate in this conversation.