Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flush/Empty db in StackExchange.Redis

I am using StackExchange.Redis in my application to store key/values. I need to flush the entire db now which Redis is using. I found a way via command How do I delete everything in Redis? but how can I do this with StackExchange.Redis? I was not able to find any method for that?

I searched for Empty, RemoveAll etc on IDatabase object and found nothing.

like image 953
Raghav Avatar asked Feb 17 '16 09:02

Raghav


1 Answers

The easiest way is to use FlushDatabase method or FlushDatabaseAsync from IServer

ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost,allowAdmin=true");
var server = redis.GetServer("localhost");
server.FlushDatabase();
like image 72
Arkhangelskiy Evgeniy Avatar answered Nov 07 '22 13:11

Arkhangelskiy Evgeniy