The data has been inserted into redis by springboot java rest api E.g.
r.put(Hash_value,key,value)
Am trying to retrieve the same using python code to print the keys There are around 5 HASH VALUES
The following is code snippet
def main():
redis_host='localhost'
redis_port=6379
redis_client=redis.StrictRedis
(host=redis_host,port=redis_port,password='pass',db=0)
for key in redis_client.scan_iter():
print(key)
keys=redis_client.keys('*')
vals=''
cnt=0
for key in keys:
type = redis_client.type(key).decode('utf-8')
print("type={}".format(type))
cnt=cnt+1
if type == "string":
print("string")
vals = redis_client.get(key)
if type == "hash":
print("hash")
print('key is {}'.format(key))
vals =redis_client.hgetall(key)
cnt1=0
u1=uuid.uuid1()
print('folln 10 keys')
for k in vals.keys():
u1=k
if cnt1 == 10:
print("before break1 ")
break
else:
cnt1=cnt1+1
print('key is {} {}'.format(cnt1,str(u1)))
#print('decode key is {}
{}'.format(cnt1,k.decode()))
#print('dump1 {}'.format(json.loads(k)))
#print('dump 2 {}'.format(simplejson.loads(k)))
key1 = pickle.dumps(k)
print(key1)
if type == "zset":
print("zset")
vals = redis_client.zrange(key, 0, -1)
if type == "list":
print("list")
vals = redis_client.lrange(key, 0, -1)
if type == "set":
print('set')
vals = redis_client. smembers(key)
if cnt == 1: break
if __name__ == "__main__":
main()
It is going into the flows of type hash and dictionary.
key1 is displayed as below .All keys are uuid. And uuid of 32 bytes or 42 bytes . i have changed some hex values below
key is 1 b'xacxedx00x05srx00x0ejava.util.UUIDxbcx99x03xf7x98mx85/x02x00x02Jx00x0cleastSigBitsJx00x0bmostSigBitsxpx94x8fxce]8x93x16xc4x82x9etzxfexd6O?'
I tried to convert this with decode(), pickle.load/dump, json.load/dump
They are not working
Pls suggest