agateblue / django-dynamic-preferences

Dynamic global and instance settings for your django project
https://django-dynamic-preferences.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
348 stars 86 forks source link

Support other cache than 'default' #261

Closed rutger-emesa closed 1 year ago

rutger-emesa commented 2 years ago

There is no way of configuring which cache should be used when caching preferences. The 'default' cache is always used. It would be nice if it were possible to configure this. Currently we have to monkey-patch the PreferencesManager to achieve this.

agateblue commented 2 years ago

Indeed, I can see how it could be an issue. I'd gladly review and merge a PR for this. If anyone wants to give it a try, you can:

  1. Add a new CACHE_NAME setting at https://github.com/agateblue/django-dynamic-preferences/blob/097c7766c2b895cd805c919ce6ac4a8a8dccc885/dynamic_preferences/settings.py (with a default to default for backward compatibility
  2. Update https://github.com/agateblue/django-dynamic-preferences/blob/07362d97a24c26158b13a58a344feaa7193846aa/dynamic_preferences/managers.py#L28 to use the CACHE_NAME setting defined in 1.
  3. A couple of lines in https://github.com/agateblue/django-dynamic-preferences/blob/develop/docs/installation.rst#settings to document this new setting