Add DriverInfo support for Redis client identification #567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds support for redis-py's
DriverInfoclass to identify fastapi-cache as an upstream driver in Redis connection metadata, following the Redis client library identification guidance.This improves observability for Redis administrators by making fastapi-cache connections easily identifiable when inspecting connected clients (e.g., via
CLIENT LISTorCLIENT INFOcommands).Changes
_add_driver_info()method toRedisBackendclassDriverInfoclass when availablelib_name/lib_versionfor older redis-py versionstests/test_redis_backend.pyMotivation
Redis recommends that client libraries identify themselves using
CLIENT SETINFOto help administrators understand which applications are connected. This change aligns fastapi-cache with this best practice by:lib-nameto identify fastapi-cache as the upstream driver (e.g.,redis-py(fastapi-cache_v0.2.2))lib-verto the redis-py client versionCompatibility
The implementation gracefully handles different redis-py versions:
DriverInfoclass (preferred method)lib_name/lib_versionfallbackTesting