我在 C# 程序中使用 StackExchange.Redis。有什么方法可以清空redis或者删除所有键值对吗?
最佳答案
您可能正在寻找 FLUSHDB
/FLUSHALL
.尽管名称如此,但这不是“数据库”级别的命令,而是“服务器”级别的命令(意思是:在 redis 集群的上下文中,它只影响一个服务器,而不是整个键空间;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 中的所有键值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52945262/