This project is a simplified Redis-like in-memory database implemented in C++, supporting both HashMap and ZSet (Sorted Set using AVL Trees) data types. The server listens to commands from a socket, processes them, and sends appropriate responses.
# 1. Create build directory
mkdir build && cd build
# 2. Generate build files
cmake ..
# 3. Compile
cmake --build .
#4,Run program for linux.Windows coming soon.
./Cereberus
You can run it either using client.c or using dart program socket.dart which is in frontend/lib/socket.dart.Or in any language that you prefer.Just follow the rules and according to them design your own client.
- HashMap DBs: Stored in a
mapsstructure (std::unordered_map<std::string, HMap>). - ZSet DBs: Stored in
mapZsetusing an AVL tree for score-ordered insertion. - Communication: Socket-based client-server system. Input commands are parsed, responses are written back using
write_to_socket.
Supports:
new: create DBput: insert key-valueget: retrieve valuedel: delete key
Supports:
zsetCreate: create DBzsetPut: insert element with scorezsetQuery: get elements in a score rangezsetDel: delete element by key
Each command follows a structure:
<command> <DB_NAME> [key] [value/score] ...
Description: Creates a new empty key-value DB.
Usage:
new myDB
Response:
built successfully
Description: Insert a key-value pair into a HashMap DB.
Usage:
put myDB user1 JohnDoe
Description: Retrieve a value by key.
Usage:
get myDB user1
Description: Delete a key-value pair.
Usage:
del myDB user1
Description: Creates a new ZSet database (AVL tree).
Usage:
zsetCreate myZDB
Description: Inserts a value with score into ZSet. Auto-creates DB if missing.
Usage:
zsetPut myZDB alice 3.5
Description: Queries ZSet elements by score range.
Usage:
zsetQuery myZDB dummyKey 2.0 5.0
Description: Deletes a key from the ZSet.
Usage:
zsetDel myZDB alice
All commands are logged with timestamps using fprintf():
[command] at time: YYYY-MM-DD HH:MM:SS
Example:
put command at time: 2025-06-12 14:32:00
- Instead of using AVL use B+ trees.
- More Secure socket communications
- Bringing it to Windows