Redis channels -- 抓取key时的WRONGTYPE操作
Redis channels -- WRONGTYPE operation when trying to grab a key
我正在使用 Channels Redis 进行 websocket 操作。但是,我想确切地查看它在 redis 中保存的内容。这将如何完成?
这是我目前的情况:
>>> import redis
>>> r = redis.Redis()
>>> r.keys()
['asgi::group:chat_hello', 'asgi::group:chat_lobby', 'asgi::group:chat_hi', 'iTunes+1068285837']
>>> r.get('asgi::group:chat_hello')
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
首先,检查有问题的密钥类型:
>>> r.type('asgi::group:chat_hello')
'zset'
是zet类型,在redis中是sorted set。要查看已排序集合的内容,您可以执行以下操作:
# r.zrange(key, 0, -1) -- 0, 1 specifies the starting and ending index,
-- where 0 is the start and -1 is the end
>>> r.zrange('asgi::group:chat_newplace', 0, -1)
['specific.AUWRSlpx!NjGkQvODgPHx']
我正在使用 Channels Redis 进行 websocket 操作。但是,我想确切地查看它在 redis 中保存的内容。这将如何完成?
这是我目前的情况:
>>> import redis
>>> r = redis.Redis()
>>> r.keys()
['asgi::group:chat_hello', 'asgi::group:chat_lobby', 'asgi::group:chat_hi', 'iTunes+1068285837']
>>> r.get('asgi::group:chat_hello')
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
首先,检查有问题的密钥类型:
>>> r.type('asgi::group:chat_hello')
'zset'
是zet类型,在redis中是sorted set。要查看已排序集合的内容,您可以执行以下操作:
# r.zrange(key, 0, -1) -- 0, 1 specifies the starting and ending index,
-- where 0 is the start and -1 is the end
>>> r.zrange('asgi::group:chat_newplace', 0, -1)
['specific.AUWRSlpx!NjGkQvODgPHx']