mafintosh / flat-file-db

Fast in-process flat file database that caches all data in memory
196 stars 15 forks source link

db.put function duplicates information #7

Closed sksar closed 8 years ago

sksar commented 8 years ago

when i run db.put('hello', {world:1}); and then at a later time after closing and reopening i run that again

i get two entries of hello?? why is this so?? from the api i am never gonna get the previous value of hello so why does the value still persists.. is there a way not to make such things happen so that the file size gets reduced

matthew-dean commented 8 years ago

Wait, does this really happen?

mafintosh commented 8 years ago

When you override 'hello' the old version is marked as garbage in the file. It will be overwritten by another put in the future. This means that you'll usually only ever have two versions of 'hello' in the file.