redis / redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

Home Page:http://redis.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sscan count does not work correctly

hahahashen opened this issue · comments

image
I create a set, which have 4 elements, which are ("user1","user2","user3","user4")
when I use command sscan, result does not match count number

please read the section Number of elements returned at every SCAN call in https://redis.io/commands/scan/

SCAN family functions do not guarantee that the number of elements returned per call are in a given range. The commands are also allowed to return zero elements, and the client should not consider the iteration complete as long as the returned cursor is not zero.

However the number of returned elements is reasonable, that is, in practical terms SCAN may return a maximum number of elements in the order of a few tens of elements when iterating a large collection, or may return all the elements of the collection in a single call when the iterated collection is small enough to be internally represented as an encoded data structure (this happens for small Sets, Hashes and Sorted Sets).

However there is a way for the user to tune the order of magnitude of the number of returned elements per call using the COUNT option.

I see. It means, redis does not guarantee that the number of the return elements is less than count?

yes, it can be less or more.

I understand, thank you!