Example #1
0
    def fixed_wrap_cache(self, key, func):
        """Return cache value ``key``, or run ``func``.
		"""
        if self.cache:
            if not self.no_cache_read:
                log.debug('Checking cache for key %s', key)
                content = self.cache.get(key)
                if not content in (False, None):
                    log.debug('Using cached result for %s', key)
                    return MemoryHunk(content)

        try:
            content = func().getvalue()
            if self.cache:
                try:
                    log.debug(
                        'Storing result in cache with key %s',
                        key,
                    )
                    self.cache.set(key, content)
                except:
                    error_logger.exception(
                        "Got an exception while trying to save file to cache, not caching"
                    )
            return MemoryHunk(content)
        except:
            error_logger.exception(
                "Got an exception while trying to apply filter, ignoring file")
            return MemoryHunk(u"")
Example #2
0
	def fixed_wrap_cache(self, key, func):
		"""Return cache value ``key``, or run ``func``.
		"""
		if self.cache:
			if not self.no_cache_read:
				log.debug('Checking cache for key %s', key)
				content = self.cache.get(key)
				if not content in (False, None):
					log.debug('Using cached result for %s', key)
					return MemoryHunk(content)

		try:
			content = func().getvalue()
			if self.cache:
				log.debug('Storing result in cache with key %s', key,)
				self.cache.set(key, content)
			return MemoryHunk(content)
		except:
			error_logger.exception("Got an exception while trying to apply filter, ignoring file")
			return MemoryHunk("")