Giter Club home page Giter Club logo

simplified-redis's Introduction

Simplified Redis

Overview:

In-memory data storage for key-value pairs๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป

Leverages Node.js' native net module to create TCP server. Data will also persist in data.json file and will reload on server start.

Supported Commands:

  • SET key value EX?: Stores the key-value pair in the database with option to set expiration in seconds.
    • returns: 'OK' upon data entry
  • GET key: Retrieves the value associated with the key.
    • returns: value of the associated key or null if key does not exist
  • DEL key/s: Deletes single or multiple key-value pair from the database.
    • returns: 0 if key does not exist, 1 if a single key-value pair is deleted, or the number of key-value pairs that has been deleted
    • note: Per Redis' forum, the DEL command does not "delete" the document. This implementation is a mix of FT.DEL command that deletes the entire document and DEL command that allows multiple key deletion.
  • EXPIRE key seconds: Sets a timeout on the specified key. After the timeout has expired, the key will be deleted.
    • returns: 0 if key does not exist or 1 if the timeout was set
  • TTL key: Returns the remaining time to live of a key that has an expiration set, in seconds.
    • returns: -2 if key does not exist, -1 if the expiration is not set, or the remaining time in seconds

Note: the return values are set to mimic Redis as closely as possible

Instructions:

  1. git clone
  2. Run npm install
  3. Write desired commands in client.ts
  4. Run npm run server
  5. In a separate terminal, run npm run client

Results will logged to the console.

To check the current state of DataStorage, see data.json file. Data will only be updated to data.json on server close to keep state management in DatatStorage.

simplified-redis's People

Contributors

msoncsswe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.