scanKeys

fun UnifiedJedis.scanKeys(pattern: String, count: Int = 100): Sequence<String>

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.

Return

a Sequence of matching key names

Parameters

pattern

the glob-style pattern to match keys against (e.g., "user:*")

count

a hint to Redis for how many keys to return per SCAN iteration