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屋!