[Django] #36879: Add Django cache identification to Redis client metadata

10 views
Skip to first unread message

Django

unread,
Jan 23, 2026, 9:42:13 AM (yesterday) Jan 23
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Type: New
| feature
Status: new | Component: Core
| (Cache system)
Version: dev | Severity: Normal
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
= Proposal: Add Django cache identification to Redis client metadata =

== Context ==

Redis documentation recommends that clients identify themselves via
connection metadata to help operators monitor, debug, and reason about
production systems (for example using ``CLIENT SETINFO`` / ``CLIENT
INFO``):

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

This information is intended to help Redis operators understand what
software is connecting to their servers, especially in shared or multi-
tenant environments.

Django’s Redis cache backend is built on top of ``redis-py``, which means
Redis connections created by Django are currently indistinguishable from
other ``redis-py``-based clients in shared Redis deployments. This makes
it harder for Redis operators to attribute traffic, diagnose issues, or
understand cache usage patterns when multiple applications or frameworks
share the same Redis instance.

== Proposal ==

Django could provide '''additional, non-invasive client identification'''
for Redis cache connections to indicate that the connection originates
from Django’s cache framework.

``redis-py`` exposes a ``driver_info`` API that may be used to attach
Django-specific context to the connection, in line with Redis’s client
identification recommendations.

== Goals ==

* Align with Redis client identification best practices
* Allow Redis operators to distinguish Django cache connections
* Improve observability in shared Redis environments

== Example (illustrative) ==

A Redis connection created by Django’s cache backend might expose metadata
equivalent to:

* Client library: ``redis-py``
* Framework / driver: ``django-cache``

== Scope ==

* This is a '''feature proposal''', not a patch submission
* No behavioral changes to caching semantics are proposed
* Any implementation would rely solely on ``redis-py``’s supported APIs
--
Ticket URL: <https://code.djangoproject.com/ticket/36879>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 23, 2026, 9:44:41 AM (yesterday) Jan 23
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Vasil Chomakov:

Old description:
New description:
* Framework: `django-cache`

== Scope ==

* This is a '''feature proposal''', not a patch submission
* No behavioral changes to caching semantics are proposed
* Any implementation would rely solely on `redis-py`’s supported APIs

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:1>

Django

unread,
Jan 23, 2026, 5:34:40 PM (21 hours ago) Jan 23
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Zachary W):

I poked around and got a working solution. Although in future versions of
`redis-py`, `lib_name` and `lib_version` are [https://github.com/redis
/redis-
py/blob/6063a86b3fa58fc504f84a98f42cee0954c95cbd/redis/connection.py#L658
deprecated], `DriverInfo` is not available for latest `redis-py` release
`v7.1.0`.

In `django/core/cache/backends/redis.py`:

{{{
class RedisCacheClient:
def _get_connection_class(self, lib):
class DjangoConnection(lib.Connection):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.lib_name = "django"
self.lib_version = django.get_version()

return DjangoConnection
def __init__(
servers,
serializer=None,
pool_class=None,
parser_class=None,
**options,
):
...

self._connection_class = self._get_connection_class(self._lib)
...
self._pool_options = {
"parser_class": parser_class,
"connection_class": self._connection_class,
**options,
}
}}}


I can make a PR once this ticket is accepted. And we'll have to update
again once `DriverInfo` for `redis-py` is released.
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:2>

Django

unread,
Jan 23, 2026, 5:37:47 PM (21 hours ago) Jan 23
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Zachary W):

* cc: Zachary W (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:3>

Django

unread,
Jan 23, 2026, 5:58:52 PM (21 hours ago) Jan 23
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Zachary W (ar3ph)):

or I can make it default to use `driver_info` when `lib_name` and
`lib_ver` are no longer supported.
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:4>

Django

unread,
9:27 AM (5 hours ago) 9:27 AM
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Zachary W (ar3ph)):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:5>

Django

unread,
9:48 AM (5 hours ago) 9:48 AM
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Vasil Chomakov):

I suggest using `DriverInfo` when available (can be successfully imported)
and falling back to `lib_name` and `lib_version` if `redis-py` does not
yet support it.

IMPORTANT: Note that when manually set, `lib_name` and `lib_version`
should look like this:
* `lib_name` = `redis-py(django-cache_v{django-cache-version})`
* `lib_version` = `{redis-py-version}`
per Redis `CLIENT SETINFO` documentation:
https://redis.io/docs/latest/commands/client-setinfo/
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:6>

Django

unread,
9:48 AM (5 hours ago) 9:48 AM
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Zachary W (ar3ph)):

Here is a `django-redis` [https://github.com/redis/redis-
py/blob/6063a86b3fa58fc504f84a98f42cee0954c95cbd/redis/driver_info.py#L82
example]. Perhaps the best solution is to just change the `lib-name` to
include our upstream driver.

The lib-name will become like `redis-py(django_v6.1.0)`
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:7>

Django

unread,
9:50 AM (5 hours ago) 9:50 AM
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Zachary W (ar3ph)):

Replying to [comment:6 Vasil Chomakov]:
> I suggest using `DriverInfo` when available (can be successfully
imported) and falling back to `lib_name` and `lib_version` if `redis-py`
does not yet support it.
>
> IMPORTANT: Note that when manually set, `lib_name` and `lib_version`
should look like this:
> * `lib_name` = `redis-py(django-cache_v{django-cache-version})`
> * `lib_version` = `{redis-py-version}`
> per Redis `CLIENT SETINFO` documentation:
https://redis.io/docs/latest/commands/client-setinfo/

Should the driver be called `django-cache`? My opinion is to just call it
`django`, b/c `django-cache` is not a separated package.
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:8>

Django

unread,
10:03 AM (5 hours ago) 10:03 AM
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Vasil Chomakov):

I agree, `django_v{django-version}` is descriptive enough.
So when using `DriverInfo`, just setting the upstream driver to
`django_v6.1.0` would suffice.
When `DriverInfo` is not available:
- `lib_name` = `redis-py(django_v6.1.0)`
- `lib_version` = `{redis-py-version}`
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:9>

Django

unread,
10:57 AM (4 hours ago) 10:57 AM
to django-...@googlegroups.com
#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
Reporter: Vasil Chomakov | Owner: (none)
Type: New feature | Status: new
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
Keywords: redis cache | Triage Stage:
observability | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Zachary W (ar3ph)):

Replying to [comment:9 Vasil Chomakov]:
> I agree, `django_v{django-version}` is descriptive enough.
> So when using `DriverInfo`, just setting the upstream driver to
`django_v6.1.0` would suffice.
> When `DriverInfo` is not available:
> - `lib_name` = `redis-py(django_v6.1.0)`
> - `lib_version` = `{redis-py-version}`

I finished this in the proposed PR. Note that `lib_version` defaults to
`redis-py` version. So nothing for us to do there.
--
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:10>
Reply all
Reply to author
Forward
0 new messages