Redis is not updating properly

546 views
Skip to first unread message

vikasreddy ncs

unread,
Oct 14, 2015, 7:58:38 AM10/14/15
to Redis DB
Hi All ,
 I tried below scenarios in Redis
1. Inserted one key with and set values against keys (key A values a:1,b:2,c:3)
2. I over rided that key with same key but with less set calues (key A values a:1,b:2)

 I see that c is still exists in redis .. Can i know how to over ride c with no value 

ddorian43

unread,
Oct 14, 2015, 8:47:39 AM10/14/15
to Redis DB
Can you please list the commands ?

The Baldguy

unread,
Oct 15, 2015, 10:11:29 AM10/15/15
to Redis DB
While you didn't say what commands you are using I suspect you are using a hash, is that correct? In this case, you didn't change anything. A has, set using hset or hmset is not a monolithic key, but a key/value mapping. You didn't delete the key, nor did you actually make any changes to it. Setting one key in the hash does not erase the others - that would be a terrible implementation and not really a hash at that point.

sudipto manna

unread,
Oct 18, 2015, 1:17:06 AM10/18/15
to Redis DB
You can override the value by parsing a new value. Until and unless you provide a new  value the original value still remains in the memory.
e.g. Original command: HMSET user name A val1 1 val2 2 val3 3
At this stage HGETALL user will print following
"name"
"A"
"val1"
"1"
"val2"
"2"
"val3"
"3"

next command HMSET user name A val1 5 val2 6
At this stage HGETALL user will print following
"name"
"A"
"val1"
"5"
"val2"
"6"
"val3"
"3"

Since val3 was unaltered so the memory holds the same value until and unless the key is deleted altogether or a new value is assigned or mapped to val3 
Reply all
Reply to author
Forward
0 new messages