Design Persistent Key Value Store
Anonymous User
2056

Implement a Key-Value Store Service which should persist its state across restarts.
A Persistent store is something that retains its state across restarts.

A Key-value Store is a service that enables a user to store a value linked to a key and it should also provide ways to retrieve that value using the key and also delete the value.
In short, perform all CRUD operations.

My approach:

Divide by first letter of key A,B,..,Z (26 Folders). Within Each folder have a length based file.

Folder Structure :
./A/1.txt
./A/2.txt
./C/7.txt

My idea is to store keys in memory and all data (keys & values) in file.
I'll maintain same lexicographical ordering of keys in memory as well as in file. So i can apply binary search and get index of the key in O(Log(n)) time.

But how to seach file and get that particular line in less than O(n) ?

Any resource/direction is appreciated.

Comments (5)