This is my implementation of Redis Server
- Requires
CMakeversion3.9.1or later. - Contains server and the client.
- Get into folder that you want to build
cd ServerORcd Client - Create directory for build and
cdthere.mkdir build && cd build - Call
cmake ..with-DCMAKE_BUILD_TYPE=Releaseor-DCMAKE_BUILD_TYPE=Debugdepending on the mode for buildcmake .. -DCMAKE_BUILD_TYPE=Release - Call
cmake --build . - In the
/binfolder you will find the executable
- Redis server that supports commands
SET <key> <value=double>- Sets the key
keywith valuevalue
- Sets the key
GET <key>- Gets the value of key
key
- Gets the value of key
DEL <key>- Deletes the key
key
- Deletes the key
RANGE <key> <score=double> <offset=int64> <limit=int64>- Get up to
limitthe keys in increasing order starting fromkey'with valueval', which is offset fromkeywith valuescorebyoffsetelements
- Get up to
EXPIRE <key> <time=int64>- Set the expiration time of key
keyto timetime
- Set the expiration time of key
TTL <key>- Gets the expiration time of key
key
- Gets the expiration time of key
- Client tests these features. In the
main.cpp, some tests are presented that can be taken as an example.
Observe that the port used by the Server is 23'232. The IP address is the same as the address of the machine where it is run.
I explain briefly, what is peculiar about my implementation in terms of the concepts that were used.
- Implementation using bare TCP sockets
- Event-driven server using
epoll - Data Structures implemented by hands to increase performance
- Hash Map
- AVL tree
- Heap
- Linked List
- Implementation of timers for using the server as cache