I am trying to fetch the redis data, then
at first try this script
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
self.redis = redis.Redis(connection_pool=pool)
for key in self.redis.keys():
print ("key:",key)
It shows like this,
key: b'asgi:group:347'
key: b'asgi:group:62'
key: b'asgi:group:344'
key: b'asgi:group:305'
key: b'asgi:group:348'
then I try to check ,
print(self.redis.get("asgi:group:348"))
However it shows the error like this,
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
How can I get the value of table?
I am trying to fetch the redis data, then
at first try this script
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
self.redis = redis.Redis(connection_pool=pool)
for key in self.redis.keys():
print ("key:",key)
It shows like this,
key: b'asgi:group:347'
key: b'asgi:group:62'
key: b'asgi:group:344'
key: b'asgi:group:305'
key: b'asgi:group:348'
then I try to check ,
print(self.redis.get("asgi:group:348"))
However it shows the error like this,
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
How can I get the value of table?
Share asked Mar 4 at 5:29 whitebearwhitebear 12.5k29 gold badges149 silver badges299 bronze badges1 Answer
Reset to default 1Redis supports multiple types of values, and you need to know the type of the value in order to fetch it. get()
only works if the value is a string.
For a key you know nothing about try calling self.redis.type(key)
to find out the type of value stored with the key. You will then need to use the appropriate getter for that type.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745060366a4608929.html
评论列表(0条)