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).
- Ensure you have install NodeJS.
npm install
- To start KeyValueStore API service.
npm start
## 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\"}"
- Run testing command.
npm run test
- All of test cases in keyValueStore.test
- integrationTests.http
- Use above http file via plugin can send HTTP request such as HTTP Client of IntelliJ or REST Client of VSCode Extension
- 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
- To prevent race condition the KeyValueStore implement lock mechanism in Locker
- Mock data has been generated in the constructor of the storeService.
- The storeService to pretend to be a DataBase store service.