scanKeys
Lazily scans Redis keys matching the given pattern using the SCAN command.
Extension function on UnifiedJedis. Returns a Sequence that iterates through all matching keys without loading them all into memory at once.
This covers a standalone server (RedisClient). A cluster client (RedisClusterClient) sends SCAN to a single node: Jedis rejects a pattern without a {hash-tag} with IllegalArgumentException, and with one it returns only the keys in that tag's slot. To scan every node of a cluster, use Jedis' own scanIteration.
Security: pattern is a Redis glob, in which *, ? and [...] are wildcards and \ escapes. A pattern built from request data must pass that data through escapeGlob first: in "session:$userId:*", a userId of * would match every user's session keys, while "session:${userId.escapeGlob()}:*" matches only the keys of a user named *.
Return
a Sequence of matching key names
Parameters
the glob-style pattern to match keys against (e.g., "user:*"); escape any part that comes from request data with escapeGlob
a hint to Redis for how many keys to return per SCAN iteration