aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-11 22:22:19 +0100
committerAymeric Augustin2013-11-11 22:56:29 +0100
commit9e06aa80a04e60506a0472e251e11b873eb8b501 (patch)
tree3f1564e4dadba17a997e55fced8178194c36d70f
parent54e69c49100be7205d1e8533ffa9373af074ed36 (diff)
downloaddjango-debug-toolbar-9e06aa80a04e60506a0472e251e11b873eb8b501.tar.bz2
Make panels cache size configurable.
-rw-r--r--debug_toolbar/toolbar/loader.py3
-rw-r--r--debug_toolbar/utils/settings.py1
-rw-r--r--docs/configuration.rst4
3 files changed, 6 insertions, 2 deletions
diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py
index 870eec3..f9262f8 100644
--- a/debug_toolbar/toolbar/loader.py
+++ b/debug_toolbar/toolbar/loader.py
@@ -100,7 +100,6 @@ def load_panel_classes():
toolbar_counter = 0
-toolbar_maxsize = 10 # keep data for the last 10 requests
toolbar_results = SortedDict()
@@ -108,7 +107,7 @@ def save_toolbar(toolbar):
global toolbar_counter, toolbar_results
toolbar_counter += 1
toolbar_results[toolbar_counter] = toolbar
- for _ in range(len(toolbar_results) - toolbar_maxsize):
+ for _ in range(len(toolbar_results) - CONFIG['RESULTS_CACHE_SIZE']):
# When we drop support for Python 2.6 and switch to
# collections.OrderedDict, use popitem(last=False).
del toolbar_results[toolbar_results.keyOrder[0]]
diff --git a/debug_toolbar/utils/settings.py b/debug_toolbar/utils/settings.py
index af9821f..12dc231 100644
--- a/debug_toolbar/utils/settings.py
+++ b/debug_toolbar/utils/settings.py
@@ -20,6 +20,7 @@ CONFIG_DEFAULTS = {
),
'ROOT_TAG_ATTRS': '',
'SQL_WARNING_THRESHOLD': 500, # milliseconds
+ 'RESULTS_CACHE_SIZE': 10,
}
diff --git a/docs/configuration.rst b/docs/configuration.rst
index 310482e..a035727 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -106,3 +106,7 @@ The debug toolbar has two settings that can be set in ``settings.py``.
'ENABLE_STACKTRACES': True,
'HIDDEN_STACKTRACE_MODULES': ('gunicorn', 'newrelic'),
}
+
+ * ``RESULTS_CACHE_SIZE``
+
+ The toolbar keeps up to this many results in memory. Defaults to 10.