* Disable in-memory cache GlobalSettings
This commit is contained in:
parent
180d1000d5
commit
44722e4fcb
|
|
@ -23,9 +23,7 @@ from django_cleanup import cleanup
|
||||||
from mptt.fields import TreeForeignKey
|
from mptt.fields import TreeForeignKey
|
||||||
from mptt.models import MPTTModel
|
from mptt.models import MPTTModel
|
||||||
|
|
||||||
from external_api.currency import client as CurrencyAPIClient
|
|
||||||
from store.utils import create_preview, concat_not_null_values
|
from store.utils import create_preview, concat_not_null_values
|
||||||
from utils.cache import InMemoryCache
|
|
||||||
|
|
||||||
|
|
||||||
class GlobalSettings(models.Model):
|
class GlobalSettings(models.Model):
|
||||||
|
|
@ -51,19 +49,12 @@ class GlobalSettings(models.Model):
|
||||||
self.__class__.objects.exclude(id=self.id).delete()
|
self.__class__.objects.exclude(id=self.id).delete()
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
InMemoryCache.set('GlobalSettings', self)
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f'GlobalSettings <{self.id}>'
|
return f'GlobalSettings <{self.id}>'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls) -> 'GlobalSettings':
|
def load(cls) -> 'GlobalSettings':
|
||||||
cached = InMemoryCache.get('GlobalSettings')
|
|
||||||
if cached:
|
|
||||||
return cached
|
|
||||||
|
|
||||||
obj, _ = cls.objects.get_or_create(id=1)
|
obj, _ = cls.objects.get_or_create(id=1)
|
||||||
InMemoryCache.set('GlobalSettings', obj)
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user