Cache backend should expose a flush method
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)
Owner: |
changed from nobody to andrewfong
|
Status: |
new → assigned
|
Triage Stage: |
Unreviewed → Accepted
|
Has patch: |
set
|
Needs documentation: |
set
|
Needs documentation: |
unset
|
Resolution: |
→ duplicate
|
Status: |
assigned → closed
|
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.