Skip to content

Commit 783ed46

Browse files
committed
Merge pull request #712 from blopker/master
Fix #670 and #570. Add 'clear()' to CacheStatTracker
2 parents 8b29127 + ea0f9f9 commit 783ed46

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

debug_toolbar/panels/cache.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ def set(self, *args, **kwargs):
8181
def delete(self, *args, **kwargs):
8282
return self.cache.delete(*args, **kwargs)
8383

84+
@send_signal
85+
def clear(self, *args, **kwargs):
86+
return self.cache.clear(*args, **kwargs)
87+
8488
@send_signal
8589
def has_key(self, *args, **kwargs):
8690
# Ignore flake8 rules for has_key since we need to support caches
@@ -148,6 +152,7 @@ def __init__(self, *args, **kwargs):
148152
('get', 0),
149153
('set', 0),
150154
('delete', 0),
155+
('clear', 0),
151156
('get_many', 0),
152157
('set_many', 0),
153158
('delete_many', 0),

tests/panels/test_cache.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def test_recording(self):
2525
cache.cache.set('foo', 'bar')
2626
cache.cache.get('foo')
2727
cache.cache.delete('foo')
28-
self.assertEqual(len(self.panel.calls), 3)
28+
# Verify that the cache has a valid clear method.
29+
cache.cache.clear()
30+
self.assertEqual(len(self.panel.calls), 5)
2931

3032
@skipIf(django.VERSION < (1, 7), "Caches was added in Django 1.7")
3133
def test_recording_caches(self):

0 commit comments

Comments
 (0)