Skip to content

Commit 0fe8566

Browse files
authored
Added config option to specify the cache to use (#270)
1 parent acbd0af commit 0fe8566

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

docs/installation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Also, take some time to look at provided settings if you want to customize the p
7272
# Use this to disable caching of preference. This can be useful to debug things
7373
'ENABLE_CACHE': True,
7474
75+
# Use this to select which chache should be used to cache preferences. Defaults to default.
76+
'CACHE_NAME': 'default',
77+
7578
# Use this to disable checking preferences names. This can be useful to debug things
7679
'VALIDATE_NAMES': True,
7780
}

dynamic_preferences/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def queryset(self):
2727
@property
2828
def cache(self):
2929
from django.core.cache import caches
30-
return caches['default']
30+
return caches[preferences_settings.CACHE_NAME]
3131

3232
def __getitem__(self, key):
3333
return self.get(key)

dynamic_preferences/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'ENABLE_GLOBAL_MODEL_AUTO_REGISTRATION': True,
2323
'ENABLE_USER_PREFERENCES': True,
2424
'ENABLE_CACHE': True,
25+
'CACHE_NAME': 'default',
2526
'VALIDATE_NAMES': True,
2627
'FILE_PREFERENCE_UPLOAD_DIR': 'dynamic_preferences',
2728
# this will be used to cache empty values, since some cache backends

0 commit comments

Comments
 (0)