db: Replace values in memory on set_value
db: Fix leak in memory get_value
db: Fix leak in memory unset_value