A Redis server implementation in Typescript from John Cricket coding challenges
A simple implementation of a Redis server written in TypeScript. Part of my attempt at John Crickett's Coding Challenges
- Basic implementation of Redis server functionality.
- Support for the RESP2 protocol.
- Support for common Redis commands.
- Autosave upon client disconnection or server shutdown.
- Loads DB for disk on startup.
- Asynchronous implementation.
- Easy to use and extend.
-
Clone the repository:
git clone https://github.com/Fuad28/redis-server.git cd redis-server
-
Install dependencies using npm:
npm init -y npm install
-
Run the Redis server:
- option 1 : run server on default port 6379
npm start
- option 2 : specify a port to run server on.
tsc && node dist/index.js -p 5000
-
The server begins to run on localhost port 6379. You can then interact with the server using redis-cli
redis-cli
You can then begin to send your commands.
PING
: Ping the server.ECHO
: Echo the input string.KEYS
: Returns all key names.LEN
: Returns the total number of keys stored.ECHO
: Echo the input string.GET
: Get the value of a key.SET
: Set the value of a key.COMMAND
: Get information about Redis commands (This wasn't implemented).EXISTS
: Check if a key exists.DEL
: Delete a key.DECR
: Decrement the value of a key by 1.LPUSH
: Add an element to the left end of a list.RPUSH
: Add an element to the right end of a list.SADD
: Add an element to a set.SMEMBER
: Displays elements of a set.RPUSH
: Add an element to the right end of a list.SAVE
: Save the dataset to disk.