Opened 14 years ago
Closed 12 years ago
#15269 closed Bug (fixed)
get_cache method should be documented as part of move to CACHES
Reported by: | Owned by: | Ian Clelland | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | cache |
Cc: | django@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
While the move to CACHES is explained in docs/topics/cache.txt, it is not clear that this allows the declaration and access of multiple caches.
An example with more than one (a non-'default') cache should be included.
An explanation of how to use get_cache
should be included, perhaps just a minor rewording of the docstring?
Function to load a cache backend dynamically. This is flexible by design to allow different use cases: To load a backend with the old URI-based notation:: cache = get_cache('locmem://') To load a backend that is pre-defined in the settings:: cache = get_cache('default') To load a backend with its dotted import path, including arbitrary options:: cache = get_cache('django.core.cache.backends.memcached.MemcachedCache', **{ 'LOCATION': '127.0.0.1:11211', 'TIMEOUT': 30, })
Change History (10)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:3 by , 14 years ago
Easy pickings: | unset |
---|
follow-up: 5 comment:4 by , 13 years ago
Cc: | added |
---|---|
UI/UX: | unset |
Before making get_cache() "public" it should IMHO changed a little bit. Because try this:
cache = get_cache('not_existing_cache')
You will get a strange traceback:
File "./django/core/cache/__init__.py", line 173, in get_cache backend, location, params = parse_backend_conf(backend, **kwargs) File "./django/core/cache/__init__.py", line 131, in parse_backend_conf mod_path, cls_name = backend.rsplit('.', 1) ValueError: need more than 1 value to unpack
Should i open a new ticket for this?
follow-up: 6 comment:5 by , 13 years ago
Replying to jedie:
Before making get_cache() "public" it should IMHO changed a little bit. Because try this:
cache = get_cache('not_existing_cache')You will get a strange traceback:
File "./django/core/cache/__init__.py", line 173, in get_cache backend, location, params = parse_backend_conf(backend, **kwargs) File "./django/core/cache/__init__.py", line 131, in parse_backend_conf mod_path, cls_name = backend.rsplit('.', 1) ValueError: need more than 1 value to unpackShould i open a new ticket for this?
Yes, please.
comment:6 by , 13 years ago
Keywords: | cache added |
---|
comment:7 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:8 by , 12 years ago
I've written up a quick paragraph about this; it's available in github at https://github.com/clelland/django/tree/ticket_15269.
Pull request forthcoming.
comment:9 by , 12 years ago
Has patch: | set |
---|
comment:10 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I think this ticket understates the problem.
Contrary to what the release notes for 1.3 say, the fact that Django supports several caches is not documented at all.
The syntax of settings.CACHES suggests that several caches could be defined, by analogy with settings.DATABASES, but there is nothing about how to use them.