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