解决redis ResponseError: [PROXY] unsupported command select

>>> from django_redis import get_redis_connection
>>> r = get_redis_connection()
>>> r.set('test', 1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/redis/client.py", line 1451, in set
    return self.execute_command('SET', *pieces)
  File "build/bdist.linux-x86_64/egg/redis/client.py", line 774, in execute_command
    connection.send_command(*args)
  File "build/bdist.linux-x86_64/egg/redis/connection.py", line 619, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "build/bdist.linux-x86_64/egg/redis/connection.py", line 594, in send_packed_command
    self.connect()
  File "build/bdist.linux-x86_64/egg/redis/connection.py", line 502, in connect
    self.on_connect()
  File "build/bdist.linux-x86_64/egg/redis/connection.py", line 576, in on_connect
    if nativestr(self.read_response()) != 'OK':
  File "build/bdist.linux-x86_64/egg/redis/connection.py", line 638, in read_response
    raise response
ResponseError: [PROXY] unsupported command select 

今天redis 加入认证机制,并采用proxy链接,先看django的caches 配置:

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://ip:6379/0",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PASSWORD": "pwd",
        }
    }
}

当我将 LOCATION 的 redis库配置为0库时,不会报错,当配置为1~15库时就会报错,所以总结为proxy做了redis后面所有库的整合,默认就是0库。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值