Examples or tutorials for writing key-value storage?

Is there any tutorials or examples of small storages of type key value? I am interested to work with the disk and how data is stored.
March 20th 20 at 12:03
1 answer
March 20th 20 at 12:05
how can I shove data into a single file


and the best does this approach for kv?

This varies from the taskthat you solve.
I'll try to explain on fingers.
Option 1
You very rarely change the database (once a month) and very often it is read (once per second). It makes sense to do so, the data was always sorted, so the search was faster. Conclusion: the need to sort the database whenever changes are made
Option 2
You frequently add new records (every second) and very rarely read them (once a month). Something like a log. It makes sense to sort only when reading. Conclusion: when added to sort the database is not necessary. Stupid entries are appended at the end of the file.

As you can see, the optimization of different and diametrically. However, the "right" optimization, no.

Find more questions by tags DatabasesData storage