A file-based key-value data store that supports the basic CRUD (create, read, update and delete) operations.
This data store is meant to be used as a local storage for one single process on one laptop. The data store must be exposed as a library to clients that can instantiate a class and work with the data store. The data store will support the following functional requirements.
- create() : Takes the key input and checks whether the key is present is in file. If the key is present, then the key-value is created and inserted.
- read() : Takes the key input and checks whether the key is present is in file. If the key is present, then the corresponding value is returned.
- delete() : Takes the key input and checks whether the key is present is in file. If the key is present, then the key-value is deleted from the file.
- update() : Takes the key input and checks whether the key is present is in file. If the key is present, then the value is modified and updated accordingly.
- The size of the file storing data must never exceed 1GB.
- More than one client process cannot be allowed to use the same file as a data store at any given time.
- A client process is allowed to access the data store using multiple threads, if it desires to. The data store must therefore be thread-safe.
- The client will bear as little memory costs as possible to use this data store, while deriving maximum performance with respect to response times for accessing the data store.
Python
- threading-Thread
- json
- sys
- os
- time
- pathlib-Path