ZSCAN

Redis 開発者教育の申込 Redis 定期点検/技術サポート
Redis Technical Support
Redis エンタープライズサーバー
Redis Enterprise Server

score、member を一定単位個数ずつ照会

使い方は zscan key cursor です。
member が多い場合はカーソル(cursor)を指定して繰り返し照会します。すべて照会した場合 next cursor は 0 です。
zrange key start, stop を使って繰り返し照会するのと似ています。
例では member 数が多くないので一度にすべて照会されました。

Example

コマンド>zadd myzip 1 A1 2 A2 3 A3 4 B1 5 B2 6 B3 7 C1 8 C2 9 C3
結果>9
コマンド>sscan myset 0
結果>next cursor -> 0
0) 1 -> A1
1) 2 -> A2
2) 3 -> A3
...
8) 9 -> C3


count を使用可能

使い方は zscan key cursor count 10 です。
照会される member 数は指定した count と常に一致するとは限りません。処理時間を考慮して個数を調節します。

Example

コマンド>zscan myzip 0 count 5
結果>next cursor -> 0
0) E1
1) A2
2) C2
...
8) 9 -> C3


pattern を使用可能

使い方は zscan key cursor match pattern です。
pattern は member に適用されます。
GLOB style pattern です。

Example

コマンド>zscan myset 0 match B*
結果>next cursor -> 0
0) 4 -> B1
1) 5 -> B2
2) 6 -> B3


構文

ZSCAN key cursor [MATCH pattern] [COUNT count]

  • このコマンドは version 2.8.0 から使用できます。
  • 時間計算量は実行1回ごとに O(1) です。
関連コマンド ZRANGE
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< ZDIFFSTORE ZSCAN ZPOPMIN >>

Email 返事がかかってなれば、メールでお知らせします。