INNER CODE UNIT · Python
default_key_builder
redis/fastapi-redis-sdk · src/redis_fastapi/cache.py:70
def default_key_builder(
request: Request,
eviction_group: str = "",
prefix: str = "",
) -> str:
"""Build a cache key from the request path and query string.
Slashes in the path are replaced with colons.
Query params are sorted and appended as ``key=value`` pairs.
When an *eviction_group* is provided it is wrapped in Redis hash-tag
braces (``{eviction_group}``) so that all keys in the same group
are guaranteed to map to the same hash slot. This is required
for Lua-based bulk eviction to work in Redis Cluster and is
harmless in standalone mode.
Args:
request: The incoming HTTP request.