Python-redis keys() returns list of bytes objects instead of strings

前端 未结 4 1612
孤独总比滥情好
孤独总比滥情好 2021-02-01 14:37

I\'m using the regular redis package in order to connect my Python code to my Redis server.

As part of my code I check if a string object is existed in my R

4条回答
  •  失恋的感觉
    2021-02-01 14:51

    Previous answers are correct in that the decode_responses connection parameter is needed to do this automatically, what they omit is that this needs to be set on the ConnectionPool instead if the connections are made using the pool. The below snippet will set the 'decode_responses' value on all clients to true, even if the client sets itself to False during connection

    pool = redis.ConnectionPool(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, password=REDIS_PWD, decode_responses=True)
    

提交回复
热议问题