fix mapupdate caching
This commit is contained in:
parent
f7824fd7c1
commit
519eeebf2f
1 changed files with 4 additions and 4 deletions
|
@ -40,7 +40,7 @@ class MapUpdate(models.Model):
|
||||||
with cls.lock():
|
with cls.lock():
|
||||||
last_update = cls.objects.latest()
|
last_update = cls.objects.latest()
|
||||||
result = last_update.to_tuple
|
result = last_update.to_tuple
|
||||||
cache.set('mapdata:last_update', result, 60)
|
cache.set('mapdata:last_update', result, 300)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -51,7 +51,7 @@ class MapUpdate(models.Model):
|
||||||
with cls.lock():
|
with cls.lock():
|
||||||
last_processed_update = cls.objects.filter(processed=True).latest()
|
last_processed_update = cls.objects.filter(processed=True).latest()
|
||||||
result = last_processed_update.to_tuple
|
result = last_processed_update.to_tuple
|
||||||
cache.set('mapdata:last_processed_update', result, 60)
|
cache.set('mapdata:last_processed_update', result, 300)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -131,7 +131,7 @@ class MapUpdate(models.Model):
|
||||||
Router.rebuild()
|
Router.rebuild()
|
||||||
|
|
||||||
transaction.on_commit(
|
transaction.on_commit(
|
||||||
lambda: cache.delete('mapdata:last_processed_update')
|
lambda: cache.set('mapdata:last_processed_updatee', new_updates[-1].totuple, 300)
|
||||||
)
|
)
|
||||||
|
|
||||||
return new_updates
|
return new_updates
|
||||||
|
@ -151,7 +151,7 @@ class MapUpdate(models.Model):
|
||||||
|
|
||||||
if new:
|
if new:
|
||||||
transaction.on_commit(
|
transaction.on_commit(
|
||||||
lambda: cache.delete('mapdata:last_update')
|
lambda: cache.set('mapdata:last_update', self.to_tuple, 300)
|
||||||
)
|
)
|
||||||
if settings.HAS_CELERY:
|
if settings.HAS_CELERY:
|
||||||
transaction.on_commit(
|
transaction.on_commit(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue