David542
David542

Reputation: 110462

Redis channels -- WRONGTYPE operation when trying to grab a key

I am using Channels Redis for websocket operations. However, I'd like to view exactly what it's saving in redis. How would this be done?

Here is what I have so far:

>>> 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

Upvotes: 0

Views: 301

Answers (1)

David542
David542

Reputation: 110462

First, check the type of the key in question:

>>> r.type('asgi::group:chat_hello')
'zset'

It is of type zet, or a sorted set in redis. To view the contents of a sorted set you can do:

# 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']

Upvotes: 1

Related Questions