summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-20 21:15:53 +0100
committerDan McGee <dan@archlinux.org>2013-02-09 23:20:38 +0100
commit8524a6057c4b99a620850494a22eb3d1f56bee68 (patch)
treee7f00207fa4e94de9393cf8a44407e349e2b95b3
parent271d1babbf8038e17d9dc5cfc3cd659463848400 (diff)
downloadarchweb-8524a6057c4b99a620850494a22eb3d1f56bee68.tar.gz
archweb-8524a6057c4b99a620850494a22eb3d1f56bee68.tar.xz
Change caching strategy on package.applicable_arches
Rather than use the Django cache for this (aka memcached), just do it on a per-object instantiation basis. This means no external services calls except the first time to the database, which should be quite a bit faster. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--main/models.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/main/models.py b/main/models.py
index da9d8b6..ec5c2bd 100644
--- a/main/models.py
+++ b/main/models.py
@@ -177,12 +177,15 @@ class Package(models.Model):
def maintainers(self, maintainers):
self._maintainers = maintainers
- @cache_function(1800)
+ _applicable_arches = None
+
def applicable_arches(self):
'''The list of (this arch) + (available agnostic arches).'''
- arches = set(Arch.objects.filter(agnostic=True))
- arches.add(self.arch)
- return list(arches)
+ if self._applicable_arches is None:
+ arches = set(Arch.objects.filter(agnostic=True))
+ arches.add(self.arch)
+ self._applicable_arches = list(arches)
+ return self._applicable_arches
@cache_function(119)
def get_requiredby(self):