2

transactionDB python api は、

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

begin <= k < end となるすべてのキー k とそれに関連付けられた値を KeyValue オブジェクトのリストとして返します。end が範囲から除外されていることに注意してください。

この読み取りは完全に同期的です。

Redisで同等のものが欲しいです。lrange 関数と zrange 関数を見ましたが、似ているとは思いません。

4

2 に答える 2

2

TL;DR there isn't a direct equivalent and scanning the entire key space is always slow(er) - you should avoid it unless your intent is getting most/all of the keys anyway.

There are two Redis commands that allow you to scan the keyspace - one is called SCAN and the other one should not be mentioned nor used for anything but development. Unlike what you're after, however, these commands: 1. Do not work on ranges of keys, but rather on glob-like patterns 2. Do not return the associated value, you have to specifically read it

Generally speaking, you should refrain from practicing such read patterns unless you mean it - in most cases, you want the responses fast and cheap, so a full scan is almost always not the right way,

于 2016-08-30T18:44:23.570 に答える
0

ソートされたセットを使用すると、範囲でクエリを実行できます。たとえばオブジェクトを保存している場合は、ソートされたセットを使用して目的のオブジェクト ID を取得し、hget / hgetallを使用してハッシュからオブジェクト情報を検索できます。

于 2016-08-30T08:36:20.390 に答える