https://github.com/ahmed-naserelden/keyvaluestore
A simple and efficient in-memory key-value store implementation that provides basic CRUD (Create, Read, Update, Delete) operations.
https://github.com/ahmed-naserelden/keyvaluestore
Last synced: 4 months ago
JSON representation
A simple and efficient in-memory key-value store implementation that provides basic CRUD (Create, Read, Update, Delete) operations.
- Host: GitHub
- URL: https://github.com/ahmed-naserelden/keyvaluestore
- Owner: Ahmed-Naserelden
- Created: 2025-05-22T18:27:31.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-05-22T23:44:20.000Z (5 months ago)
- Last Synced: 2025-06-03T06:38:14.248Z (5 months ago)
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Key-Value Store
A command-line based key-value store implementation with namespace and table support, persistence, and compaction features.
## Features
- Namespace and table management
- CRUD operations (Create, Read, Update, Delete)
- Data persistence with flush operations
- Table compaction
- Interactive command-line interface
- TTL (Time To Live) support for key-value pairs## Requirements
- Python 3.9 or higher
## Installation
1. Clone the repository
2. Navigate to the project directory
3. Run `python3 cli.py`## Usage
The key-value store provides an interactive shell with the following commands:
### Namespace Management
- `create-namespace ` - Create a new namespace
- `use-namespace ` - Switch to a namespace
- `list-namespaces` - List all available namespaces### Table Management
- `create-table ` - Create a new table in current namespace
- `list-tables` - List all tables in current namespace### Data Operations
- `set :: [ttl]` - Set a key-value pair (optional TTL)
- `get :` - Retrieve a value by key
- `delete :` - Delete a key-value pair
- `flush ` - Flush table data to disk
- `compact ` - Compact table files### Example Session
```bash
kvstore> create-namespace iti
[OK] Created namespace: itikvstore> use-namespace iti
[OK] Using namespace: itikvstore> create-table collaborators
[OK] Created table: iti:collaboratorskvstore> set collaborators:collaborator1:sief
[OK] Set collaborator1 in iti:collaboratorskvstore> get collaborators:collaborator1
[HIT] iti:collaborators:collaborator1 = siefkvstore> flush collaborators
[OK] Flushed iti:collaborators to disk.
```## Project Structure
```
key_value_store/
├── cli.py # Command-line interface
├── kvstore/ # Core implementation
│ ├── engine.py # Main storage engine
│ ├── store/ # Storage implementation
│ └── wal.py # Write-ahead logging
└── testcases.txt # Example usage scenarios
```## Commands Reference
- `exit` - Exit the interactive shell
- `create-namespace ` - Create a new namespace
- `use-namespace ` - Switch to a namespace
- `list-namespaces` - List all namespaces
- `create-table ` - Create a new table
- `list-tables` - List all tables in current namespace
- `set :: [ttl]` - Set a key-value pair
- `get :` - Get a value by key
- `delete :` - Delete a key-value pair
- `flush ` - Flush table to disk
- `compact ` - Compact table files