推荐学习书目
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 · Feb 10, 2023 · 3736 views
    This topic created in 1211 days ago, the information mentioned may be changed or developed.

    前段时间开源了 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 replies    2023-02-15 17:25:19 +08:00
    Nazz
        1
    Nazz  
       Feb 10, 2023 via Android
    我也写过一个内存缓存库,使用 hashmap 和 heap 实现 ttl
    matrix1010
        2
    matrix1010  
    OP
       Feb 10, 2023
    @Nazz heap 也可以,似乎 Go 自带的 timer 就是通过 heap 实现的
    matrix1010
        3
    matrix1010  
    OP
       Feb 10, 2023
    有兴趣的也可以看看我在 reddit 上发的这个帖子: https://www.reddit.com/r/Python/comments/10xnpjh/python_deserves_a_good_inmemory_cache_library/
    mongodb
        4
    mongodb  
       Feb 15, 2023
    很好,不用啥都塞 redis 了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5330 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 09:10 · PVG 17:10 · LAX 02:10 · JFK 05:10
    ♥ Do have faith in what you're doing.