Opened 69 minutes ago
Closed 65 minutes ago
#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
See you in #36830!