#37153 closed New feature (duplicate)

Store the cache alias on the cache backend instance

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

Description

Store the alias used to fetch a cache backend instance on the instance itself. The Django Debug Toolbar is having to do some extra patching (django-commons/django-debug-toolbar#2219) to retain what alias is being used for which cache. While tolerable, it means the toolbar is having to reimplement more parts of Django, making it more brittle for future versions.

django/new-features: https://github.com/django/new-features/issues/95

Ideal code:

from django.core.cache import cache

print(cache.alias)
# "default"

I believe we need to make the following changes:

  • Update CacheHandler.create_connection to pass alias as backend_cls(location, params, alias=alias)
  • Update django.core.cache.backends.base.BaseCache.init to accept and store alias

Change History (1)

comment:1 by Jacob Walls, 65 minutes ago

Resolution: duplicate
Status: newclosed

See you in #36830!

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