A simple key-value store built in Python, exposing a RESTful HTTP interface for CRUD operations. The entire implementation relies solely on Python's standard library, with no external dependencies.
- Python 3.7+
- Docker
-
Build the Docker image:
make docker-build
-
Run the Docker container:
make docker-run
The server will be accessible at
http://localhost:8000.
To run the tests, execute the following command from the root of the project:
make testThis command will discover and run all tests in the tests directory.
You can interact with the key-value store using any HTTP client, such as curl.
-
Create/Update a key-value pair:
curl -X POST -H "Content-Type: application/json" -d '{"value": "your_value"}' http://localhost:8000/store/your_key
-
Retrieve a value by key:
curl http://localhost:8000/your_key
-
Delete a key:
curl -X DELETE http://localhost:8000/your_key
While I've implemented a DB to allow for persistence our our key-value store I wasn't able to finish the implementation in time. As such the app defaults to using the in-memory DB which means data doesn't actually persist between runs. I don't think this would take long to fix at all but it has knock-on effects on the tests and requires updating the makefile to ensure our directory is mounted.
Overall the abstraction of the Database, Cache and Store could probably serve to be improved. Additionally there should be some mechanism whereby the story in the webserver can also be configured (using something like Depedency Injection) for greater flexibility and testability.