Redis.Cluster.Scan (Redis v0.8.0)

Copy Markdown View Source

Cluster-wide SCAN — iterates keys across all master nodes transparently.

Usage

{:ok, cluster} = Redis.Cluster.start_link(nodes: [{"127.0.0.1", 7000}])

# Scan all keys matching a pattern
{:ok, keys} = Redis.Cluster.Scan.scan(cluster, match: "user:*")

# Stream-based (lazy) scanning
Redis.Cluster.Scan.stream(cluster, match: "user:*", count: 100)
|> Enum.take(50)

Options

  • :match - glob pattern (default: "*")
  • :count - hint for number of keys per SCAN call (default: 100)
  • :type - filter by key type ("string", "list", "set", etc.)

Summary

Functions

Scans all keys across the cluster, returning the full list. Use stream/2 for large keyspaces.

Returns a Stream that lazily scans all cluster nodes. Each element is a key string.

Functions

scan(cluster, opts \\ [])

@spec scan(
  GenServer.server(),
  keyword()
) :: {:ok, [String.t()]} | {:error, term()}

Scans all keys across the cluster, returning the full list. Use stream/2 for large keyspaces.

stream(cluster, opts \\ [])

@spec stream(
  GenServer.server(),
  keyword()
) :: Enumerable.t()

Returns a Stream that lazily scans all cluster nodes. Each element is a key string.