Redis Stack Exchange如何按模式删除或获取密钥 [英] Redis Stack Exchange how to delete or get keys by pattern
问题描述
我在C#中安装了Stack Exchange redis客户端.我只能删除一个键或键数组,但不知道如何删除带前缀的键.或者另一种解决方案是先按模式获取所有密钥,然后将其删除.但是我也不知道如何通过模式来获取密钥.
I installed Stack Exchange redis client in C#. I can only delete one key or array of keys but I don't know how to delete keys with prefix. Or another solution can be first get all keys by pattern and then delete them. But I don't know how to get keys by pattern too.
推荐答案
删除操作是用键分开的,除非要刷新整个数据库.
Deletion is separate by key, unless you are flushing the entire database.
密钥扫描可在 IServer
API上轻松获得,并在此处进行了更多讨论: https://stackexchange.github.io/StackExchange.Redis/KeysScan
Key scanning is readily available on the IServer
API, and is discussed much more here: https://stackexchange.github.io/StackExchange.Redis/KeysScan
但是,通常仍应在生产中避免使用它-这不是Redis的预期用例.
However, it should still usually be avoided in production - that isn't the intended use-case for redis.
这篇关于Redis Stack Exchange如何按模式删除或获取密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!