/redis-server

An implementation of redis server in Typescript

Primary LanguageTypeScript

A Redis server implementation in Typescript from John Cricket coding challenges

Redis Server implementation in Typescript

ts

A simple implementation of a Redis server written in TypeScript. Part of my attempt at John Crickett's Coding Challenges

Features

  • 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.

Installation

  1. Clone the repository:

    git clone https://github.com/Fuad28/redis-server.git
    cd redis-server
  2. Install dependencies using npm:

    npm init -y
    npm install

Usage

  1. 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
  2. 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.

Supported 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.

Basic example

Screenshot 2024-03-08 at 8 54 31 PM