This project is a key-value storage system divided into two parts:
A basic key-value store with an added feature - each key has a specified timeout (in seconds), and the value associated with the key will be automatically deleted once the timeout period elapses.
Click to expand and see endpoints
-
Get Value
- URL:
/get
- Method:
GET
- Parameters:
key
- Example:
curl -X GET "http://localhost:5000/get?key=1"
- Response:
{ "current_time": "Thu, 11 Jan 2024 21:09:21 GMT", "time_out": "Thu, 11 Jan 2024 21:09:26 GMT", "value": "hello" }
- URL:
-
Set Key-Value:
- URL:
/set
- Method:
GET
- Parameters:
key
,value
,timeout
(in seconds) - Example:
curl -X GET "http://localhost:5000/set?key=1&value=hello&timeout=10"
- Response:
{ "key": "1", "message": "Value set successfully", "timeout": "Thu, 11 Jan 2024 21:09:37 GMT", "value": "hello" }
- URL:
-
Delete Value:
- URL:
/delete
- Method:
GET
- Parameters:
key
- Example:
curl -X GET "http://localhost:5000/delete?key=1"
- Response:
{ "message": "Value deleted successfully" }
- URL:
-
Retrieve all data:
- URL:
/all
- Method:
GET
- Example:
curl -X GET "http://localhost:5000/all"
- Response:
{ "1": { "time_out": "Thu, 11 Jan 2024 21:12:31 GMT", "value": "hello" } }
- URL:
-
Clone the Repository:
git clone https://github.com/GoutamVerma/key_value_store.git cd key_value_store
-
Set Up Virtual Environment:
python3 -m venv .venv source .venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Run Simple Key-Value Store:
- Navigate to the
key-value
directory. - Run the service:
python3 app.py
- Navigate to the
-
Run test cases(optional but recommended):
python3 app.test.py
An enhanced version of the key-value store where the data is distributed among various services. The services perform CRUD operations with a locking system, allowing only one process at a time to access the resources (similar to the concept of semaphores).
Note: Endpoints are similar to key-value
-
Clone the Repository:
git clone https://github.com/GoutamVerma/key_value_store.git cd key_value_store
-
Set Up Virtual Environment:
python3 -m venv .venv source .venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Run Distributed Key-Value Store:
- Navigate to the distributed key-value directory.
- Run the service:
python3 service.py
-
Run test cases(optional but recommended):
python3 test.service.py
Note: Ensure that git, python3, and pip are installed on your system. Make sure to activate the virtual environment before running the services. Run test cases to validate the functionality of the key-value stores.