As hmset call doesn't remove old values this fuctionality
worked incorrectly and old values were not removed.
For example, removing 'PrereleaseDir' from repos.yaml and loading
it to the database was not removing this field in Redis.
Fixes: #2070
Change-Id: Ida42bd2a24a128b0f82f67bcc2a3b3905ff49920
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
key = "%s%s" % (self._prefix, key)
if isinstance(value, dict):
mvalue = deepcopy(value)
+ # delete fields which are not present in new value
+ for field in self._db.hgetall(key).keys():
+ if field not in mvalue:
+ self._db.hdel(key, field)
+ # dump jsoned fields
for field in self.jsoned:
mvalue[field] = json.dumps(value[field])
self._db.hmset(key, mvalue)