0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Redis の SCAN の COUNT について

Posted at

Redis の SCAN の COUNT について、ネットに二通りの解釈があったので、どっちが正解かを確認します。

二通りの解釈

ネットには以下の様に異なる解釈が存在していました。

前提として、SCAN に該当するキーは redis に十分にあるものとします。

(1)

The default value is 10. It means the command will bring back more or less 10 keys,

COUNT が 100 の時は、おおよそ 100 個のキーが返ってくる。
100 個のキーに達するまで、探索を続ける。

(2)

The COUNT is the number of keys to search through at a time per cursor iteration.

COUNT が 100 の時は、100 個を検索対象とする。
0~100 個のキーが返ってくる。

公式Doc

Basically with COUNT the user specifies the amount of work that should be done at every call in order to retrieve elements from the collection.

公式Doc にはこのように書いてありますが、"work" ってなんだ?,... となり、分からなかったので 以下の issue で確認しました。

結論

結論は (1) です。

ちなみに

ぴったり 100 個返ってこないのは、バケットの途中で探索をやめることをしないからです。
load factor とかで調べると仕組みが分かると思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?