V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
a719114136

django-redis-ex | 为 Django Redis 添加原生异步支持

  •  
  •   a719114136 ·
    gojuukaze · Aug 7, 2024 · 2263 views
    This topic created in 637 days ago, the information mentioned may be changed or developed.

    django-redis-ex

    基这个库于 Django 官方的 RedisCache 修改,完美兼容 Django 。采用原生异步方式创建 Redis client ,并相比同时支持异步、同步方法。另外,这个库修复了官方库的连接池 bug (#35651)。

    User guide

    Installation

    pip install django-redis-ex
    

    Configure as cache backend

    CACHES = {
        "default": {
            "BACKEND": "django_redis_ex.async_cache.AsyncRedisEXCache",
            "LOCATION": "redis://127.0.0.1:6379",
        }
    }
    

    配置参数说明请参阅官方文档。

    你也可以使用修复了 bug 的同步 cache 。

    CACHES = {
        "default": {
            "BACKEND": "django_redis_ex.cache.RedisEXCache",
            "LOCATION": "redis://127.0.0.1:6379",
        }
    }
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4621 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 10:09 · PVG 18:09 · LAX 03:09 · JFK 06:09
    ♥ Do have faith in what you're doing.