mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Handle more caching exception pathways (#6678)
This commit is contained in:
parent
60f3e849e7
commit
c185a267da
@ -226,9 +226,12 @@ class BaseInvenTreeSetting(models.Model):
|
|||||||
"""
|
"""
|
||||||
cache_key = f'BUILD_DEFAULT_VALUES:{str(cls.__name__)}'
|
cache_key = f'BUILD_DEFAULT_VALUES:{str(cls.__name__)}'
|
||||||
|
|
||||||
|
try:
|
||||||
if InvenTree.helpers.str2bool(cache.get(cache_key, False)):
|
if InvenTree.helpers.str2bool(cache.get(cache_key, False)):
|
||||||
# Already built default values
|
# Already built default values
|
||||||
return
|
return
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
existing_keys = cls.objects.filter(**kwargs).values_list('key', flat=True)
|
existing_keys = cls.objects.filter(**kwargs).values_list('key', flat=True)
|
||||||
@ -251,7 +254,10 @@ class BaseInvenTreeSetting(models.Model):
|
|||||||
)
|
)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
cache.set(cache_key, True, timeout=3600)
|
cache.set(cache_key, True, timeout=3600)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def _call_settings_function(self, reference: str, args, kwargs):
|
def _call_settings_function(self, reference: str, args, kwargs):
|
||||||
"""Call a function associated with a particular setting.
|
"""Call a function associated with a particular setting.
|
||||||
|
@ -34,7 +34,10 @@ def currency_code_default():
|
|||||||
code = 'USD' # pragma: no cover
|
code = 'USD' # pragma: no cover
|
||||||
|
|
||||||
# Cache the value for a short amount of time
|
# Cache the value for a short amount of time
|
||||||
|
try:
|
||||||
cache.set('currency_code_default', code, 30)
|
cache.set('currency_code_default', code, 30)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return code
|
return code
|
||||||
|
|
||||||
|
@ -748,7 +748,11 @@ def check_user_role(user, role, permission):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Save result to cache
|
# Save result to cache
|
||||||
|
try:
|
||||||
cache.set(key, result, timeout=3600)
|
cache.set(key, result, timeout=3600)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user