Skip to content

Cache the result of res.render, supports querystring whitelisting and validation.

Notifications You must be signed in to change notification settings

AlexMeah/express-redis-render-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The tests in this module flush Redis DB 15 to change the test DB use REDIS_DB=num to override


Usage

Requires Node V6

Redis Client Setup

const redis = require('redis');
const client = redis.createClient();

app.set('redis', client); // The middleware reads its Redis client from app

Cache Key generation

const supportedQuerystrings = {
    key: true, // Accepts all values
    complex: (value) => {} // Return a boolean
};

Basic

    const cache = expressRedisCache.create(supportedQuerystrings);

    app.use(cache);

Named

    const cache = expressRedisCache.create('blogPosts', supportedQuerystrings);

    app.use('/blog', cache); // OR
    app.use(cache);

About

Cache the result of res.render, supports querystring whitelisting and validation.

Resources

Stars

Watchers

Forks

Packages