且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从redis中的散列中获取与特定模式匹配的所有键?

更新时间:2023-02-23 12:09:43

Redis 不直接支持:http://redis.io/commands#hash

Redis does not support this directly: http://redis.io/commands#hash

您仅限于一次查询所有键或按其确切名称指定的一个或多个键.这种使用模式可能意味着您需要一个散列加上另一个数据结构(例如集合)来记录有趣的键,或者两个或多个单独的散列.由于 Redis 支持一次对多个结构进行原子更新,因此这通常是可行的方法.

You are limited to querying all keys at once or one or more keys specified by their exact name. This usage pattern probably means you need a hash plus another data structure (e.g. set) to keep record of the interesting keys, or two or more separate hashes. Since Redis supports atomic updates to multiple structures at once this is usually the way to go.