Python 函数缓存(qbit)
文章目录
前言
- 本文的 Python 3.8 适用
- 截至 2021.4.14,
functools.lru_cache和cachetools都不支持异步函数的缓存(async)
functools.lru_cache
- 官方标准库: functools.lru_cache
- 给
lru_cache增加生命周期管理: https://stackoverflow.com/que...
cachetools
- pypi: https://pypi.org/project/cach...
- github: https://github.com/tkem/cache...
- 文档: https://cachetools.readthedoc...
cachetools v4.2.1 已实现缓存机制
FIFO: First In First Out,先进先出 LFU: Least Frequently Used,最小频率使用,淘汰一段时间内使用次数最少的 LRU: Least Recently Used,最近最少使用,淘汰最长时间没有被使用的 MRU: Most Recently Used,(淘汰)最近最多使用 RR: Random Replacement,随机替换 TTL: time-to-live,每个条目按生存时间淘汰
qbit snap
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论