KegDB is a Java implementation of a key-value store based on the Bitcask paper (Bitcask: A Log-Structured Hash Table for Fast Key/Value Data). It implements a Redis-compatible protocol (RESP) for client communication.
- Redis-compatible protocol (RESP)
- Persistent storage using log-structured file format
- Concurrent access support
- Data integrity verification using checksums
- Configurable settings via properties file
PING
- Test server connectivityGET key
- Retrieve a value by keySET key value
- Store a key-value pairDEL key
ORDELETE key
- Delete a key-value pair
Configuration is managed through src/main/resources/db.properties
:
port=6379 # Server port (default: 6379)
thread_pool_size=10 # Number of worker threads
data_directory=./db # Data storage directory
max_file_size=10000000 # Maximum size for data files (10MB)
- Java 17 or higher
- Maven
mvn clean package
java -jar target/kegdb.jar
KegDB implements the Bitcask design with the following components:
- KeyDir: In-memory hash table mapping keys to file locations
- Data Files: Append-only log files storing the actual data
- RESP Protocol: Redis-compatible communication protocol
- Concurrent Access: Thread-safe operations using read-write locks