Ai
4 Star 0 Fork 0

纸豪/Yanyuan SwapHub

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cache.py 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
class Cache:
def __init__(self):
self.user_cache: dict[str, dict[str, any]] = {}
self.product_cache: dict[str, dict[str, any]] = {}
def get_user_cache(self, user_id: str) -> dict[str, any]:
return self.user_cache.get(user_id, {})
def set_user_cache(self, user_id: str, value: dict[str, any]):
self.user_cache[user_id] = value
def delete_user_cache(self, user_id: str):
del self.user_cache[user_id]
def clear_user_cache(self):
self.user_cache.clear()
def get_product_cache(self, product_id: str) -> dict[str, any]:
return self.product_cache.get(product_id, {})
def set_product_cache(self, product_id: str, value: dict[str, any]):
self.product_cache[product_id] = value
def delete_product_cache(self, product_id: str):
del self.product_cache[product_id]
def clear_product_cache(self):
self.product_cache.clear()
def clear_all_cache(self):
self.user_cache.clear()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhihao2023/yanyuan-swap-hub.git
git@gitee.com:zhihao2023/yanyuan-swap-hub.git
zhihao2023
yanyuan-swap-hub
Yanyuan SwapHub
master

搜索帮助