Suor on master
Add command to clear stale cach… (compare)
Suor on master
Fix `invalidate_m2o` for polymo… (compare)
Suor on master
docs: Fix a few typos (#433) T… (compare)
CACHEOPS_REDIS = "redis://localhost:6379/1"
CACHEOPS_DEFAULTS = {
'timeout': 60*60
}
CACHEOPS = {
'*.*': {},
}
CACHEOPS_DEGRADE_ON_FAILURE = True
CACHEOPS = {
'api.Topic': {'ops': 'all', 'cache_on_save': True}, # cache all operations Topic model
'api.Subscriber': {'ops': 'all', 'cache_on_save': True}, # cache all operations Subscriber model
'api.SubscriberContract': {'ops': 'all', 'cache_on_save': True}, # cache all operations SubscriberContract model
}
ops
to all
def get_a(start, end):
start_str = start.date().isoformat()
end_str = end.date().isoformat()
key = '%s-%s' % (start_str, end_str)
@cached_as(extra=key, timeout=30 * 60)
def _get_a():
a = some_function_call()
# do not want to cache results if a are empty
if len(a.keys()) == 0:
e = UncachedResult(a)
raise e
return a
try:
return _get_a()
except UncachedResult, e:
return e.result
@cached(timeout=30 * 60)
def _get_a(start, end):
a = some_function_call()
# Do cache empty results
if not a:
raise UncachedResult(a)
return a
def get_a(start, end):
start_str = start.date().isoformat()
end_str = end.date().isoformat()
try:
return _get_a(start, end)
except UncachedResult as e:
return e.result
@cached(timeout=30 * 60)
def _get_a(start, end):
a = some_function_call(start, end)
# Do cache empty results
if not a:
raise UncachedResult(a)
return a
def get_a(start, end):
try:
return _get_a(start, end)
except UncachedResult as e:
return e.result
_get_a()
?
_get_a.invalidate(start, end)