コード例 #1
0
def set_cache(my_object, cache_name, cache_days=14, force=False, fallback=None):
    cache_name = get_pickle_name(cache_name or '')
    if my_object and cache_name and cache_days:
        _cache.set('{}.{}'.format(_cache_name, cache_name), my_object, expiration=get_timedelta(days=cache_days))
    elif force:
        my_object = my_object or fallback
        cache_days = force if isinstance(force, int) else cache_days
        _cache.set('{}.{}'.format(_cache_name, cache_name), my_object, expiration=get_timedelta(days=cache_days))
    return my_object
コード例 #2
0
 def set_cache(self, my_object, cache_name, cache_days=14, force=False, fallback=None):
     self._cache = self._cache or SimpleCache(filename=self._filename, mem_only=self._mem_only)
     cache_name = get_pickle_name(cache_name or '')
     if my_object and cache_name and cache_days:
         self._cache.set(cache_name, my_object, expiration=get_timedelta(days=cache_days))
     elif force:
         my_object = my_object or fallback
         cache_days = force if isinstance(force, int) else cache_days
         self._cache.set(cache_name, my_object, expiration=get_timedelta(days=cache_days))
     return my_object
コード例 #3
0
 def set_cache(self,
               my_object,
               cache_name,
               cache_days=14,
               force=False,
               fallback=None):
     self.ret_cache()
     cache_name = get_pickle_name(cache_name or '')
     if my_object and cache_name and cache_days:
         self._cache.set(cache_name, my_object, cache_days=cache_days)
     elif force:
         my_object = my_object or fallback
         cache_days = force if isinstance(force, int) else cache_days
         self._cache.set(cache_name, my_object, cache_days=cache_days)
     return my_object
コード例 #4
0
def get_cache(cache_name):
    cache_name = get_pickle_name(cache_name or '')
    return _cache.get('{}.{}'.format(_cache_name, cache_name))
コード例 #5
0
 def get_cache(self, cache_name):
     self._cache = self._cache or SimpleCache(filename=self._filename, mem_only=self._mem_only)
     return self._cache.get(get_pickle_name(cache_name or ''))
コード例 #6
0
 def get_cache(self, cache_name):
     self.ret_cache()
     return self._cache.get(get_pickle_name(cache_name or ''))
コード例 #7
0
def get_cache(cache_name):
    cache_name = get_pickle_name(cache_name or '')
    return _cache.get(u'{}.{}'.format(CACHE_NAME, cache_name))