We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
models.py
class Some(CachingMixin, models.Model): id = models.UUIDField( primary_key=True, default=uuid4, editable=False, verbose_name='uuid', ) rate = models.FloatField( validators=[ MinValueValidator(0.0001), MaxValueValidator(999999999999), ], null=False, verbose_name='rate', ) objects = CachingManager() def __str__(self): return ( f'| ID:{self.id} |' f'RATE: {self.rate} |' ) class Meta: verbose_name = 'Some' verbose_name_plural = "somes" base_manager_name = 'objects' index_together = [ ('rate'), ]
tasks.py
if not Some.objects.all(): objs = [Some(rate=0.0)] Some.objects.bulk_create(objs) else: qs = Some.objects.filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').first() if qs: print('############################') objs1 = [] # print(Some.objects.filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').values()) zz = Some.objects.filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').first() print(zz.rate) qs.rate = 4.3 objs1.append(qs) try: if objs1: Some.objects.bulk_update( objs1, fields=['rate',] ) except Exception as e: print(e) zz1 = Some.objects.filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').first() print(zz1.rate) zz1 = Some.objects.no_cache().filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').first() print(zz1.rate) zz2= Some.objects.filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').values('rate').first() print(zz2) print('############################')
out:
[2023-05-15 03:38:06,971: WARNING/ForkPoolWorker-2] ############################ [2023-05-15 03:38:06,973: WARNING/ForkPoolWorker-2] 4.1 [2023-05-15 03:38:06,980: WARNING/ForkPoolWorker-2] 4.1 [2023-05-15 03:38:06,983: WARNING/ForkPoolWorker-2] 4.3 [2023-05-15 03:38:06,985: WARNING/ForkPoolWorker-2] {'rate': 4.3} [2023-05-15 03:38:06,985: WARNING/ForkPoolWorker-2] ############################
zz1 = Some.objects.filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').first() print(zz1.rate) # == 4.1 zz1 = Some.objects.no_cache().filter(id='d1197bd5-7901-496f-aee1-86cfeb887ece').first() print(zz1.rate) # == 4.3
I update record in database, but django-cache-machine not update cache value. And next query get not updated value from cache. Why? How to fix this?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
models.py
tasks.py
out:
I update record in database, but django-cache-machine not update cache value. And next query get not updated value from cache. Why? How to fix this?
The text was updated successfully, but these errors were encountered: