add methods to know if there's something in cache (#6977)
This commit is contained in:
parent
a14e84fd93
commit
f0d27a7f86
|
@ -90,6 +90,14 @@ class Renderer(template.TemplateRenderer):
|
|||
if settings.TEMPLATE_DEBUG:
|
||||
yield 'blurp_debug__', '\n'.join(self.debug_content(context))
|
||||
|
||||
def has_cached_content(self, context):
|
||||
for source in self.config['sources']:
|
||||
slug = '{0}.{1}'.format(self.slug, source['slug'])
|
||||
data = Data(slug, self.config, source, context)
|
||||
if not data.has_cached_content():
|
||||
return False
|
||||
return True
|
||||
|
||||
def debug_content(self, context):
|
||||
try:
|
||||
yield u'config: {0}'.format(pprint.pformat(self.config))
|
||||
|
@ -319,6 +327,10 @@ class Data(object):
|
|||
UPDATE_THREADS = {}
|
||||
CONDITIONS = {}
|
||||
|
||||
def has_cached_content(self):
|
||||
self.__content, until = cache.get(self.key, (self.__CACHE_SENTINEL, None))
|
||||
return self.__content is not self.__CACHE_SENTINEL
|
||||
|
||||
def get_content(self):
|
||||
if self.__content is not self.__CACHE_SENTINEL:
|
||||
return self.__content
|
||||
|
|
Reference in New Issue