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: abdelazer@… 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 Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Łukasz Rekucki, 14 years ago

Severity: Normal
Type: Bug

comment:3 by Aymeric Augustin, 14 years ago

Easy pickings: unset

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.

comment:4 by jedie, 13 years ago

Cc: django@… 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?

in reply to:  4 ; comment:5 by Jannis Leidel, 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 unpack

Should i open a new ticket for this?

Yes, please.

in reply to:  5 comment:6 by jedie, 13 years ago

Keywords: cache added

Replying to jezdez:

Replying to jedie:

Should i open a new ticket for this?

Yes, please.

done -> #16410

Last edited 13 years ago by Jannis Leidel (previous) (diff)

comment:7 by Ian Clelland, 12 years ago

Owner: changed from nobody to Ian Clelland
Status: newassigned

comment:8 by Ian Clelland, 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 Ian Clelland, 12 years ago

Has patch: set

comment:10 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In e758ecc628bb1d8960d0a59a140a43d7103e89e4:

Merge pull request #386 from clelland/ticket_15269

Fixed #15269 - Added documentation for get_caches function

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