Remove All Keys from Redis in PHP
Asked Answered
O

2

5

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

Odalisque answered 6/11, 2017 at 10:20 Comment(2)
Are you using any redis PHP library (like e.g. Predis?)Alliber
yes I should include thatOdalisque
O
11

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();

Odalisque answered 6/11, 2017 at 10:21 Comment(3)
Laravel also allows you to use \Cache::store("redis")->flush()Alliber
yes that one works too. but it deletes the current db keys or all ?Odalisque
If the underlying CacheStore is RedisStore it just calls flushDB. The advantage is though that if you have code line \Cache::flush() then it will keep working when you switch from redis to something else.Alliber
A
-1
Route::get( '/verify-email/{id}', [
    \App\Http\Controllers\ApiAuth\VerifyEmailController::class,
    'index'
] )->name( 'verification.verify
Arbil answered 2/7 at 4:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.