#36836 closed New feature (wontfix)

Add version identification to Redis cache backend

Reported by: Vasil Chomakov Owned by:
Component: Core (Cache system) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The Redis documentation recommends that clients identify themselves using the lib_name and lib_version connection parameters. This helps Redis operators monitor connections and debug issues in production environments.

See: https://redis.io/docs/latest/commands/client-setinfo/

Django's Redis cache backend should follow this recommendation by automatically setting these parameters when creating connection pools.

Proposed implementation:

  • Set lib_name to 'redis-py(django_v{version})'
  • Set lib_version to the redis-py version
  • Only set these if not already provided by the user (backward compatible)

Change History (3)

comment:1 by Ahmed Asar, 83 minutes ago

Hi,
I’d like to work on this ticket.
I’ll investigate how the Redis backend creates connections and propose a patch implementing CLIENT SETINFO with the suggested defaults, unless already provided by the user.

Please let me know if that sounds good.

comment:2 by Vasil Chomakov, 31 minutes ago

Has patch: set

PR created: https://github.com/django/django/pull/20476

This adds lib_name and lib_version parameters to Redis connections to identify Django clients, making it easier for Redis operators to monitor and debug production environments.

comment:3 by Simon Charette, 112 seconds ago

Resolution: wontfix
Status: newclosed

Django only uses the redis package for providing a caching backend so it seems inapropriate to override the lib_name and lib_version that redis-py already sets by itself.

Per Redis docs

lib-name - meant to hold the name of the client library that's in use.

(Pdb) pp client.client_info()
{...
 'lib-name': 'redis-py',
 'lib-ver': '7.1.0',
 ...
 }

Moreover it seems that redis.Connection(lib_name) and lib_info are deprecated so we'd want to use driver_info instead.

If we were to change change lib_name I think it should be along the lines of redis-py(django-cache) as these connections are only meant to be used for this purpose but just like each new feature this should be proposed and discussed first per the documented process.

Note: See TracTickets for help on using tickets.
Back to Top