Django连接redis

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "CONNECTION_POOL_KWARGS": {"max_connections": 100},
            # "PASSWORD": "密码",
            "DECODE_RESPONSES":True
        }
    },
}

from django.core.cache import cache




cache.set('server_md5_token', 'd', 10)



res = cache.has_key('server_md5_token')

 

posted @ 2019-08-27 20:11  hui1019  阅读(1151)  评论(0编辑  收藏  举报