def pop_cache(func):
"""
删除缓存
"""
@functools.wraps(func)
async def wrapped(*args, **kwargs):
_cache = func._cache
for key, value in _cache.copy().items():
value = await value
if not isinstance(value, dict) and key in _cache:
_cache.pop(key)
elif 'success' not in _cache and key in _cache:
_cache.pop(key)
elif not value['success'] and key in _cache:
_cache.pop(key)
return await func(*args, **kwargs)
return wrapped
python 在返回出错的情况下删除缓存
猜你喜欢
转载自blog.csdn.net/weixin_43883907/article/details/86737029
今日推荐
周排行