如何通过StackExchange.Redis删除redis中的所有键值
how can I delete all the key-value in redis through StackExchange.Redis
我在 C# 程序中使用 StackExchange.Redis。有什么方法可以清除redis或者删除所有键值对吗?
您可能正在寻找 FLUSHDB
/ FLUSHALL
. Despite the name, this is not a "database" level command, but rather is a "server" level command (meaning: in the context of a redis cluster, it only impacts one server, not the entire keyspace; this distinction is explained more here),因此它是从 SE.Redis 中的 IServer
访问的:
ConnexctionMultiplexer redis = ...
var server = redis.GetServer({your server here});
server.FlushDatabase(); // or await server.FlushDatabaseAsync();
我在 C# 程序中使用 StackExchange.Redis。有什么方法可以清除redis或者删除所有键值对吗?
您可能正在寻找 FLUSHDB
/ FLUSHALL
. Despite the name, this is not a "database" level command, but rather is a "server" level command (meaning: in the context of a redis cluster, it only impacts one server, not the entire keyspace; this distinction is explained more here),因此它是从 SE.Redis 中的 IServer
访问的:
ConnexctionMultiplexer redis = ...
var server = redis.GetServer({your server here});
server.FlushDatabase(); // or await server.FlushDatabaseAsync();