Search code examples
phplaravelredispredis

Remove All Keys from Redis in PHP


I was able to flash all keys from terminal using redis-cli flushdb. I have been searching for a while, took me an hour in order to find the simple command to do it in php.

I didn't find it on stackoverflow so I wanted to post it to save someone precious time.

Library Used: Predis


Solution

  • If you have the redis connection you can simply do $redis->flushDB(); to delete all keys from the selected database.

    Or if you are using laravel framework you could also do Redis::flushDB();