Exemple #1
0
 def retrieve(cls):
     try:
         return pickle.loads(CacheService.get(cls.cache_key))
     except KeyError:
         LogService.warning("Attempted to retrieve '%s' but it was empty. Repopulating..." % cls.cache_key)
         cls.populate()
         return pickle.loads(CacheService.get(cls.cache_key))
Exemple #2
0
 def retrieve(cls):
     """
     Retrieve the cache's value
     :return: Various
     """
     try:
         return CacheService.get(cls.cache_key)
     except KeyError:
         LogService.warning("Attempted to retrieve '%s' but it was empty. Repopulating..." % cls.cache_key)
         cls.populate()
         return CacheService.get(cls.cache_key)
Exemple #3
0
 def invalidate(cls):
     """
     Invalidate (delete) the cache value and key.
     :return: None
     """
     LogService.info("Invalidating cache key %s" % cls.cache_key)
     return CacheService.delete(cls.cache_key)
Exemple #4
0
 def populate(cls):
     CacheService.set(cls.cache_key, pickle.dumps(IngredientTree()))
Exemple #5
0
 def populate(cls):
     serialized_citations = [
         ObjectSerializer.serialize(citation, 'dict')
         for citation in Bibliography().citations
     ]
     CacheService.set(cls.cache_key, json.dumps(serialized_citations))
Exemple #6
0
 def populate(cls):
     serialized_notes = [
         ObjectSerializer.serialize(note, 'dict')
         for note in Notebook().notes
     ]
     CacheService.set(cls.cache_key, json.dumps(serialized_notes))
Exemple #7
0
from flask_caching import Cache as FlaskCache
from barbados.services.cache import CacheService

flask_cache = FlaskCache(config=CacheService.get_flask_config())