Пример #1
0
    def cache_image_file(self, image_id, image_file):
        """
        Cache an image file.

        :param image_id: Image ID
        :param image_file: Image file to cache

        :retval True if image file was cached, False otherwise
        """
        CHUNKSIZE = 64 * 1024 * 1024

        return self.cache_image_iter(image_id,
                utils.chunkiter(image_file, CHUNKSIZE))
Пример #2
0
 def get_from_cache(self, image_id):
     """Called if cache hit"""
     with self.cache.open_for_read(image_id) as cache_file:
         chunks = utils.chunkiter(cache_file)
         for chunk in chunks:
             yield chunk
Пример #3
0
 def get_from_cache(self, image_id):
     """Called if cache hit"""
     with self.cache.open_for_read(image_id) as cache_file:
         chunks = utils.chunkiter(cache_file)
         for chunk in chunks:
             yield chunk