mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
bitbake: toaster: Add an invalidate cache method on data update signal
Instead of relying on the cache expiring over an amount of time we can listen to the changed notification on the models to invalidate the cache. Also fixes overlapping cache names. (Bitbake rev: eb0b1450e421cf65b407b1ac0336ac24ffc626e8) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
2de01a68eb
commit
e5aa569d47
@@ -26,6 +26,7 @@ from django.utils import timezone
|
||||
|
||||
from django.core import validators
|
||||
from django.conf import settings
|
||||
import django.db.models.signals
|
||||
|
||||
class GitURLValidator(validators.URLValidator):
|
||||
import re
|
||||
@@ -1176,3 +1177,14 @@ class LogMessage(models.Model):
|
||||
message=models.CharField(max_length=240)
|
||||
pathname = models.FilePathField(max_length=255, blank=True)
|
||||
lineno = models.IntegerField(null=True)
|
||||
|
||||
def invalidate_cache(**kwargs):
|
||||
from django.core.cache import cache
|
||||
try:
|
||||
cache.clear()
|
||||
except Exception as e:
|
||||
print "Problem with cache backend: Failed to clear cache"
|
||||
pass
|
||||
|
||||
django.db.models.signals.post_save.connect(invalidate_cache)
|
||||
django.db.models.signals.post_delete.connect(invalidate_cache)
|
||||
|
||||
Reference in New Issue
Block a user