1.0.0 • Published 7 years ago

microservice-cache-middleware v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Middleware to cache request in node apps

This module caches all GET and HEAD request and it expires everything in the cache when it receives a POST, PUT, DELETE or PATCH request. The results are cached in a Redis Database.

Installation

npm install --save microservice-cache-middleware

Configuration

Add this library as a middleware in your app. Example:

    app.use(require('microservice-cache-middleware')({
        prefix: 'dataset',
        redisUrl: process.env.REDIS_URL
    }));

Config params:

namedescriptiontypedefaultValuerequired
prefixPrefix text of the keys in redistextnoneyes
redisUrlRedis connection urltextnoneyes
maxAgeExpire time (Seconds)number246060no
hashFunction to obtain a hash of each requestfunctionurl of the requestno