From: "Slava Bacherikov" <slava@bacherikov.org.ua>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/templatetags/
Date: Sun, 15 Jul 2012 23:08:22 +0000 (UTC) [thread overview]
Message-ID: <1342376399.689d86c9bec5bfb98a6ee86fc13b31f26e04e3bc.bacher09@gentoo> (raw)
commit: 689d86c9bec5bfb98a6ee86fc13b31f26e04e3bc
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 15 18:19:59 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 15 18:19:59 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=689d86c9
Cache last update value
---
gpackages/apps/packages/templatetags/packages.py | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/gpackages/apps/packages/templatetags/packages.py b/gpackages/apps/packages/templatetags/packages.py
index 62e067a..a2021e4 100644
--- a/gpackages/apps/packages/templatetags/packages.py
+++ b/gpackages/apps/packages/templatetags/packages.py
@@ -1,5 +1,6 @@
from django.utils.safestring import mark_safe
from django import template
+from django.core.cache import cache
register = template.Library()
@@ -9,13 +10,18 @@ from ..forms import ArchChoiceForm, FilteringForm
@register.inclusion_tag('last_updated.html')
def last_updated():
- try:
- l = RepositoryModel.objects.only('updated_datetime'). \
- latest('updated_datetime')
- except RepositoryModel.DoesNotExist:
- return {'las_updated' : None}
- else:
- return {'last_updated': l.updated_datetime}
+ updated = cache.get('last_updated_t')
+ if not updated:
+ try:
+ l = RepositoryModel.objects.only('updated_datetime'). \
+ latest('updated_datetime')
+ except RepositoryModel.DoesNotExist:
+ updated = None
+ else:
+ updated = l.updated_datetime
+ cache.set('last_udpated_t', updated)
+
+ return {'last_updated': updated}
@register.inclusion_tag('keywords_table.html')
def render_keywords_table(obj, arch_list):
next reply other threads:[~2012-07-15 23:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-15 23:08 Slava Bacherikov [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-07-31 23:20 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/templatetags/ Slava Bacherikov
2012-07-06 23:09 Slava Bacherikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342376399.689d86c9bec5bfb98a6ee86fc13b31f26e04e3bc.bacher09@gentoo \
--to=slava@bacherikov.org.ua \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox