koa-boost
Cache middleware for koa
Last updated 3 years ago by fortis .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install koa-boost 
SYNC missed versions from official npm registry.

koa-boost

Build Status Coverage Status

Cache middleware for koa. It stores the responses matching a given pattern.

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.

Current Tags

  • 1.0.5                                ...           latest (3 years ago)

5 Versions

  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (12)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |