diff options
| author | Aymeric Augustin | 2013-11-11 22:22:19 +0100 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-11 22:56:29 +0100 |
| commit | 9e06aa80a04e60506a0472e251e11b873eb8b501 (patch) | |
| tree | 3f1564e4dadba17a997e55fced8178194c36d70f | |
| parent | 54e69c49100be7205d1e8533ffa9373af074ed36 (diff) | |
| download | django-debug-toolbar-9e06aa80a04e60506a0472e251e11b873eb8b501.tar.bz2 | |
Make panels cache size configurable.
| -rw-r--r-- | debug_toolbar/toolbar/loader.py | 3 | ||||
| -rw-r--r-- | debug_toolbar/utils/settings.py | 1 | ||||
| -rw-r--r-- | docs/configuration.rst | 4 |
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. |
