search

Home  >  Q&A  >  body text

python2.7 - django cannot connect to redis

Django wants to use redis for caching. Unable to connect to redis.

#setting.py中
CACHES={
    "default":{
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "127.0.0.1:6379",
        'OPTIONS': {
            #"CLIENT_CLASS": "redis_cache.client.DefaultClient",
            "DB": 0,
            "PARSER_CLASS": "redis.connection.HiredisParser",
            "CONNECTION_POOL_CLASS": "redis.BlockingConnectionPool",
            "PICKLE_VERSION": -1     
        }
    }
}

#views.py
def testCache(request):

    print cache
    print dir(cache)
    mn = cache.get("test2")
    return HttpResponse(mn)


Please give me some guidance, why can’t I connect?

怪我咯怪我咯2750 days ago674

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:20:54

    'LOCARION' is this a typo?

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 13:20:54

     'LOCATION': 'redis://127.0.0.1:6379/4',

    reply
    0
  • Cancelreply