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
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
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
def get_cache(cache_name): cache_name = get_pickle_name(cache_name or '') return _cache.get('{}.{}'.format(_cache_name, cache_name))
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 ''))
def get_cache(self, cache_name): self.ret_cache() return self._cache.get(get_pickle_name(cache_name or ''))
def get_cache(cache_name): cache_name = get_pickle_name(cache_name or '') return _cache.get(u'{}.{}'.format(CACHE_NAME, cache_name))