Skip to content

The KeyValueStore is a key-value in-memory store service with cache mechanism written in NodeJS programming language.

Notifications You must be signed in to change notification settings

max9159/keyValueStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeyValueStore

The KeyValueStore is a key-value in-memory store service with cache mechanism written in NodeJS programming language.

It including a fake store service getting data from DataBase (Mock data would be generated in-memory) and cache mechanism to practice any design-patten.

Currently, it supports the thread-safe with Locks and cache replacement policy FIFO (Also flexible to change policy by injection).

Installation

npm install

Getting Started

  • To start KeyValueStore API service.
npm start

API Request Example

## GET
curl --location --request GET "http://localhost:3000/api/store?key=3"

## POST
curl --location --request POST "http://localhost:3000/api/store" --header "Content-Type: application/json" --data-raw "{ \"key\": \"3\", \"value\": \"value3\"}"

Unit-Tests

  • Run testing command.
npm run test

API-Tests

Configuration

  • cacheConfigs
    • Can setup cache service's MAXIMUM_BYTES_SIZE and REPLACEMENT_POLICY
    • Currently supports FIFO, can add new strategy and implement the same as interface of fifoStrategy.js

Lock in NodeJS

  • To prevent race condition the KeyValueStore implement lock mechanism in Locker

Mock Data

  • Mock data has been generated in the constructor of the storeService.
  • The storeService to pretend to be a DataBase store service.

About

The KeyValueStore is a key-value in-memory store service with cache mechanism written in NodeJS programming language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published