core.redis_cluster_keys module

Helpers for keys used together by Redis Lua scripts.

Redis Cluster requires every key touched by one EVAL to resolve to the same hash slot. When an existing stream key is untagged, placing that complete key inside a sidecar key’s {...} hash tag produces the same CRC16 input and therefore the same slot without renaming the stream.

core.redis_cluster_keys.colocated_sidecar_key(prefix, anchor_key, suffix)

Build a sidecar key in the same Redis Cluster slot as anchor_key.

Return type:

str

Parameters:
core.redis_cluster_keys.redis_hash_tag(key)

Return the hash-tag bytes Redis Cluster uses for key.

Untagged keys use their complete key as the tag so a new sidecar can be colocated without changing the existing anchor key. Malformed/empty brace forms are rejected because embedding them would silently select a different substring and produce CROSSSLOT at runtime.

Return type:

str

Parameters:

key (str)