Closed YamiOdymel closed 7 years ago
Why would something like this happened?
The db file is an append-only file. It's normal to find duplicates in the file. The db file is only used to load the database into memory when the database is opened, otherwise it's just a log. BuntDB will automatically keep the file small by periodically shrinking it, so you won't need to worry about it growing out of control.
Do I have to check the key does exist or not before I Set the key?
No. The Set
operation will update an existing key or create a new key.
Sorry for reopening this, but can you provide more information about the "shrink" process? I mean it deletes older values I suppose, but under what condition?
The shrink process doesn’t delete anything. It creates a new file from the working in-memory data and overwrites the old file.
I'm playing around with BuntDB with this code (and executed it few times):
And I opened the
data.db
file I saw this.Why would something like this happened? I thought BuntDB will overwrite the key, value but it just added another record.
Do I have to check the key does exist or not before I
Set
the key? If so, should I useGet
to check it before ISet
it?