This is a basic implementation of Redis in C++14 with some queries like -
- GET(https://redis.io/commands/get)
- SET(https://redis.io/commands/set)
- EXPIRE(https://redis.io/commands/expire)
- ZADD(https://redis.io/commands/zadd)
- ZRANK(https://redis.io/commands/zrank)
- ZRANGE(https://redis.io/commands/zrange)
Note: The database is saved in a file named dump.txt. Therefore, the data is persistent and will load the next time you run the program. But because of the same reason the data can be lost if this file is deleted. You need to have g++(x >= 11) to avoid any errors.
https://github.com/aman-19/Redis-Man.git
g++ -o main main.cpp RedisObj.cpp AVLTree.cpp Node.cpp
./main
g++ -o main main.cpp RedisObj.cpp AVLTree.cpp Node.cpp
main.exe
SET <key> value(string)
GET <key>
EXPIRE <key> <time-in-sec>
ZADD <set-name> <score1(float)> <element1(string)> <score2> <element2> ...
ZRANK <set-name> <element(string)>
ZRANGE <set-name> <start(int)> <end(int)>
SAVE NOW
EXIT NOW
SET key val
GET key
ZADD setKey 1 val1 2 val2....
SAVE NOW
ZRANK setKey val
ZRANGE setKey 0 9
EXIT NOW