Skip to content

fortis/koa-boost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-boost

Greenkeeper badge

travis-ci status coverage status npm version Standard - JavaScript Style Guide

Cache middleware for koa.

Installation

npm install koa-boost --save

Usage

Store Cache in Application Memory
const Koa = require('koa')
const boost = require('koa-boost')

const app = new Koa()
app.use(boost({
  pattern: '/api/*',
  ttl: 60 // 60 seconds
}));
Use Redis as Cache Provider
const Koa = require('koa')
const boost = require('koa-boost')
const Redis = require('ioredis')

const app = new Koa()
const redis = new Redis()
app.use(boost({
  provider: redis,
  pattern: '/api/*',
  ttl: 60 // 60 seconds
}));

Options

  • pattern {string|array} — pattern to match incoming request paths against. Supports glob matching and other features provided by highly optimized wildcard and glob matching library micromatch. Defaults to null — all requests will be cached.
  • ttl {integer} — time in seconds that cached response should remain in the cache. Defaults to 60 seconds.