TransactionDB 的 getRange 在 Redis 中的等价物是什么?

What is the Redis equivalent of TransactionDB's getRange?

transactionDB python api 说,

Database.get_range(begin, end[, limit, reverse, streaming_mode])

Returns all keys k such that begin <= k < end and their associated values as a list of KeyValue objects. Note the exclusion of end from the range.

This read is fully synchronous.

我想要 Redis 中的等价物。我查看了 lrange 和 zrange 函数,但认为它们并不相似。

Sorted sets allow you to query by a range. If you're storing say an object, you can use the sorted set to get the desired object ID's, then lookup the object information from a hash with hget/hgetall.

TL;DR 没有直接的等价物并且扫描整个密钥 space 总是很慢(呃)——你应该避免它,除非你的意图是无论如何都要获得密钥的 most/all .

有两个 Redis 命令可让您扫描密钥space - 一个名为 SCAN and the other one 的命令不应被提及,也不应用于开发以外的任何用途。但是,与您所追求的不同,这些命令: 1. 不要处理键的范围,而是处理类似 glob 的模式 2.不要return关联值,你要专门看

一般来说,除非您是认真的,否则您应该避免练习这种阅读模式 - 在大多数情况下,您希望响应速度快且成本低,因此完全扫描几乎总是不正确的方法,