Reputation: 41
I have created a hash in redis database and i have put some keys and their values in it. I want now to delete everything that is in the hash.I am using hdel but i cannot make it work. I am confused on what should be in hdel(...) and the documentation doen't help me.Right now i have the following:
test_hash = redis_cache.hgetall(hash_name)
for key,value in test_hash.items():
i = redis_cache.hdel(hash_name,*key)
in hdel.() i have tried many different things but nothing seems to work.After the code "deletes" everything in the hash, i can still do redis_cache.hgetall() and get the same keys and values. Anyone that knows something more? I am using Python.
Upvotes: 0
Views: 2344
Reputation: 41
Ok , i found what i was doing wrong. I have to create a list of keys and do the following :
list = []
for key,value in test_hash.items():
list.append(key)
i = redis_cache.hdel(hash_name,*list)
Upvotes: 1