I am using StackExchange.Redis client with Azure Redis Cache Service. Here is my class,
public class RedisCacheService : ICacheService
{
private readonly ISe
Both answers by @Rasi and @Marc Gravell contain pieces of code needed. Based on above, here is working snippet assuming there is just 1 server:
You need to connect to redis with allowAdmin=true
, one way to obtain such options is to assign AllowAdmin to already parsed string:
var options = ConfigurationOptions.Parse("server:6379");
options.AllowAdmin = true;
var redis = ConnectionMultiplexer.Connect(options);
Then to flush all databases:
var endpoints = redis.GetEndPoints();
var server = redis.GetServer(endpoints[0]);
server.FlushAllDatabases();
Above will work on any redis deployment, not just Azure.