Cache / Idempotent controller for ExpressJs
const express = const app = const idempotency = ;let redis = client = redis; let counter = 0;app; app app
Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
Installation is done using the
npm install
command:
$ npm install express$ npm install redis$ npm install express-idempotent-redis
Features
- Works as Cache for Express using Redis
- Focus on high performance
- Guarantees Idempotent calls for all HTTP verbs
Guide
- The API caller needs to send a IdEmpotent key on header (Default is 'IDEmpKey')
- The builder accepts the following parameters:
- redisClient => Mandatory. This will be your already initiated Redis Client
- idempotencyKey => The key that will be monitored (Default is 'IDEmpKey')
- sleepTime => As your route will only be executed once, this is how long subsequent calls should wait for the main (first) request to finish (in miliseconds)
- secondsToCache => How long the request should be cached
Important
The middleware parses all results. If you want to receive a non parsed JSON string. You should add avoidParse: True to the header