V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
matrix1010
V2EX  ›  Python

高性能 Python 内存缓存: Theine

  •  
  •   matrix1010 ·
    Yiling-J · 2023-02-10 12:21:50 +08:00 · 2630 次点击
    这是一个创建于 434 天前的主题,其中的信息可能已经有所发展或是发生改变。

    前段时间开源了 Python 的异步缓存框架 Cacheme ,现在把其中的内存缓存部分单独抽出来作为一个 library ,有兴趣的可以试用一下.

    Theine: https://github.com/Yiling-J/theine

    Benchmarks: https://github.com/Yiling-J/cacheme-benchmark

    类似于Caffeine(Java)/Ristretto(Go)/Moka(Rust),具有以下特点:

    • 高性能,核心数据结构(W-TinyLFU, timer wheel)使用 Rust 编写
    • W-TinyLFU 缓存驱逐策略,流量倾斜度高的情况下有很好的命中率
    • 通过 hierarchical timer wheel 定期自动删除过期缓存
    4 条回复    2023-02-15 17:25:19 +08:00
    Nazz
        1
    Nazz  
       2023-02-10 13:16:51 +08:00 via Android
    我也写过一个内存缓存库,使用 hashmap 和 heap 实现 ttl
    matrix1010
        2
    matrix1010  
    OP
       2023-02-10 13:36:44 +08:00
    @Nazz heap 也可以,似乎 Go 自带的 timer 就是通过 heap 实现的
    matrix1010
        3
    matrix1010  
    OP
       2023-02-10 21:21:59 +08:00
    有兴趣的也可以看看我在 reddit 上发的这个帖子: https://www.reddit.com/r/Python/comments/10xnpjh/python_deserves_a_good_inmemory_cache_library/
    mongodb
        4
    mongodb  
       2023-02-15 17:25:19 +08:00
    很好,不用啥都塞 redis 了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   895 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:19 · PVG 05:19 · LAX 14:19 · JFK 17:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.