diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-05-19 16:10:19 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-29 11:59:45 +0100 |
commit | e5aa569d475347e89636f6bf677d40df4455d027 (patch) | |
tree | 8ea0b9ca8eb786c0465b89f1f3b2745513bc6cf8 /bitbake/lib/toaster/orm/models.py | |
parent | 2de01a68eb6a9ca74384957c674928944c235269 (diff) | |
download | poky-e5aa569d475347e89636f6bf677d40df4455d027.tar.gz |
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>
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 0f725764d5..fb62a55d71 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -26,6 +26,7 @@ from django.utils import timezone | |||
26 | 26 | ||
27 | from django.core import validators | 27 | from django.core import validators |
28 | from django.conf import settings | 28 | from django.conf import settings |
29 | import django.db.models.signals | ||
29 | 30 | ||
30 | class GitURLValidator(validators.URLValidator): | 31 | class GitURLValidator(validators.URLValidator): |
31 | import re | 32 | import re |
@@ -1176,3 +1177,14 @@ class LogMessage(models.Model): | |||
1176 | message=models.CharField(max_length=240) | 1177 | message=models.CharField(max_length=240) |
1177 | pathname = models.FilePathField(max_length=255, blank=True) | 1178 | pathname = models.FilePathField(max_length=255, blank=True) |
1178 | lineno = models.IntegerField(null=True) | 1179 | lineno = models.IntegerField(null=True) |
1180 | |||
1181 | def invalidate_cache(**kwargs): | ||
1182 | from django.core.cache import cache | ||
1183 | try: | ||
1184 | cache.clear() | ||
1185 | except Exception as e: | ||
1186 | print "Problem with cache backend: Failed to clear cache" | ||
1187 | pass | ||
1188 | |||
1189 | django.db.models.signals.post_save.connect(invalidate_cache) | ||
1190 | django.db.models.signals.post_delete.connect(invalidate_cache) | ||