Expand description
Turning identifiers into storage keys without letting two of them collide.
Ports the derivation upstream added in _filesystem._storage_key_segment
and applied to its Redis history keys (#8236).
§The problem
A store that addresses a record by joining identifiers — {prefix}:{id} —
is only unambiguous while no identifier can contain the separator. Nothing
constrains them: a session id is whatever the caller (or the caller’s
users) put in it. So prefix="chat", id="a:b" and prefix="chat:a",
id="b" address the same key, and two conversations that should be
isolated share one list. In a multi-tenant deployment, where the prefix
is the tenant boundary, that is one tenant reading another’s history.
storage_key_segment makes each segment unambiguous before it is
joined, so no identifier can impersonate a separator.
Functions§
- storage_
key_ segment - Render
valueas one unambiguous storage-key segment.