Skip to content

Conversation

@vchomakov
Copy link

@vchomakov vchomakov commented Dec 22, 2025

This PR adds client identification to Redis connections created by Flask-Caching, allowing Redis operators to see which library is connecting to their servers.

Redis servers support the lib_name and lib_version parameters (introduced in redis-py) to help operators identify which upstream libraries are connecting. This improves observability and debugging for Redis operators.

Following redis-py best practices, lib_name and lib_version identify the upstream library (Flask-Caching) rather than redis-py itself.

Implementation

  • Added get_flask_caching_version() utility function to retrieve the Flask-Caching version using importlib.metadata with fallback to __version__
  • Added add_redis_version_info() utility function to set lib_name="Flask-Caching" and lib_version=<version>
  • Updated RedisCache.factory(), RedisSentinelCache.factory(), and RedisClusterCache.factory() to call add_redis_version_info()
  • Only sets these parameters if not already provided by the user, ensuring user-provided values are never overridden

CI Workflow Fix

This PR also fixes the deprecated GitHub Actions versions that were causing all CI runs to fail:

  • actions/checkout@v2v4
  • actions/setup-python@v2v5
  • actions/cache@v2v4

These actions were deprecated by GitHub and enforcement started recently, causing all workflow runs (including scheduled jobs) to fail. This fix unblocks CI for this PR and all future contributions.

Testing

  • Added unit tests in tests/test_backend_cache.py to verify version identification behavior
  • All existing tests pass (122 passed, 80 skipped)
  • Type checking passes with mypy
  • Style checks pass with flake8

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add Flask-Caching version identification to Redis connections

1 participant