* Disable in-memory cache GlobalSettings

This commit is contained in:
Phil Zhitnikov 2023-12-22 00:18:03 +04:00
parent 8e49176351
commit bd3ea89166

View File

@ -23,9 +23,7 @@ from django_cleanup import cleanup
from mptt.fields import TreeForeignKey
from mptt.models import MPTTModel
from external_api.currency import client as CurrencyAPIClient
from store.utils import create_preview, concat_not_null_values
from utils.cache import InMemoryCache
class GlobalSettings(models.Model):
@ -51,19 +49,12 @@ class GlobalSettings(models.Model):
self.__class__.objects.exclude(id=self.id).delete()
super().save(*args, **kwargs)
InMemoryCache.set('GlobalSettings', self)
def __str__(self) -> str:
return f'GlobalSettings <{self.id}>'
@classmethod
def load(cls) -> 'GlobalSettings':
cached = InMemoryCache.get('GlobalSettings')
if cached:
return cached
obj, _ = cls.objects.get_or_create(id=1)
InMemoryCache.set('GlobalSettings', obj)
return obj
@property