This project is a simple Redis-like server implemented in Rust. It supports a subset of Redis commands and can be used as a lightweight in-memory key-value store.
- Supported Commands:
GET: Retrieve the value of a key.SET: Set the value of a key.DEL: Delete a key.EXISTS: Check if a key exists.KEYS: List all keys matching a pattern.INCR: Increment the integer value of a key.DECR: Decrement the integer value of a key.PING: Respond withPONG.ECHO: Echo back the provided argument.FLUSHALL: Clear all keys in the database.GETALL: Retrieve all keys and values in the database.QUIT: Close the connection.
redis-cli -h 127.0.0.1 -p 6380
-
Set a key:
SET mykey "Hello" -
Get a key:
GET mykey -
Delete a key:
DEL mykey -
Check if a key exists:
EXISTS mykey -
List all keys:
KEYS * -
Increment a key:
INCR counter -
Decrement a key:
DECR counter -
Ping the server:
PING -
Echo a message:
ECHO "Hello, World!" -
Flush all keys:
FLUSHALL -
Get all keys and values:
GETALL -
Quit the session:
QUIT
-
src/core/: Contains the core logic for handling commands and managing the database.cmd.rs: Defines theCommandsenum and command handlers.db.rs: Implements the in-memory database.expiry.rs: (Optional) Handles key expiration.resp_parser.rs: Parses Redis Serialization Protocol (RESP) messages.resp_encoder.rs: Encodes responses in RESP format.
-
src/server.rs: Implements the TCP server and connection handling.