Opened 15 years ago

Closed 14 years ago

#11503 closed (duplicate)

Cache backend should expose a flush method

Reported by: andrewfong Owned by: andrewfong
Component: Core (Cache system) Version: dev
Severity: Keywords: flush
Cc: david@…, chris@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The low level cache interface (django.core.cache.cache) should expose a method to flush out the entire cache. The primary use of this, off the top of my head, would be to make it easier to test caching by flushing out everything in between tests, although there are probably other use cases as well.

Currently, in order to do this, you have to rely on different methods for each backend. For example, with the memcached backend, you call cache._cache.flush_all(), whereas with locmem, you set cache._cache = {}. Having backends implement a flush method would make this consistent across all supported backend options.

Attachments (2)

patch.diff (9.1 KB ) - added by andrewfong 15 years ago.
Exposes a flush method that clears the cache for each backend + tests. Also, since culling and flushing are related (e.g. when the cull frequency is 0), I refactored some of the culling code to use the flush method instead. Accordingly, I've added tests to make sure culling is still working correctly.
11503-docs.diff (741 bytes ) - added by David Reynolds 15 years ago.
Tiny documentation patch describing .flush()

Download all attachments as: .zip

Change History (9)

comment:1 by andrewfong, 15 years ago

Owner: changed from nobody to andrewfong
Status: newassigned

comment:2 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

by andrewfong, 15 years ago

Attachment: patch.diff added

Exposes a flush method that clears the cache for each backend + tests. Also, since culling and flushing are related (e.g. when the cull frequency is 0), I refactored some of the culling code to use the flush method instead. Accordingly, I've added tests to make sure culling is still working correctly.

comment:3 by andrewfong, 15 years ago

Has patch: set
Needs documentation: set

by David Reynolds, 15 years ago

Attachment: 11503-docs.diff added

Tiny documentation patch describing .flush()

comment:4 by David Reynolds, 15 years ago

Needs documentation: unset

Added a quick patch with some documentation for flush()

comment:5 by David Reynolds, 15 years ago

Cc: david@… added

comment:6 by Chris Adams, 14 years ago

Cc: chris@… added

comment:7 by anonymous, 14 years ago

Resolution: duplicate
Status: assignedclosed

#12671 added a clear() method to the cache backends.

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