comoga/django-constance — pull request #45 by lorenzocolombini (2013-10-07 13:02:01+00:00)
Title: deploy internal cache of keys dict in config.py

The idea behind this pull request is to retrieve all keys in only 1 query, caching all keys in an internal dict into config.py in order to remove the need on the apps to query on every request the backend, with one query for every key value.

The update of internal cached keys dict occurs when someone change a value in admin backend (you can see query involved with debug toolbar plugin) or in your views when you modify the logic in order to retrieve another costance key.

In other situation the request user directly the internal cache dict in config.py.

I implemented this behavior for minimizing the number of query to backend for better performance in a project with a large number of requests.

In order to make optionally this behaviors, I add a new key for constance settings RETRIEVE_ALL_KEYS (default to false)

Regards
Lorenzo