0.0.1-dev • Published 4 years ago
fastify-cache-dedupe v0.0.1-dev
fastify-cache-dedupe
TODO intro
Quick Start
const cache = require('fastify-cache-dedupe')
const app = require('fastify')()
app.register(cache, {
  ttl: 60,
  // see matching (TODO)
  request: {
    method: ['GET', 'OPTIONS'],
    url: true // any url
  }
})
app.get('/', {
  cache: {
    ttl: 10,
    request: {
      // do not cache requests that have "Authorization"
      headers: (headers) => !headers.authorization
    }
    xheaders: false // do not set "x-cache" header to tell miss or hit
  }
}, 
async (request, reply) => {
  return { hello: 'world' }
})
await app.listen(3000)Options
TODO
plugin and route options
- ttl
- storage (see async dedupe)
- onDedupe (see async dedupe)
- onHit (see async dedupe)
- onMiss (see async dedupe)
- onError (see async dedupe)
- references (see async dedupe)
- invalidate (see async dedupe)
- xheaders
- request (see matching)- method
- url
- query
- body
- headers
 
route: cache: false disable cache for the single route
Matching
TODO
Invalidation
TODO
Caveats
- dedupe requires ttlminimum 1 second
- streamare not supported
0.0.1-dev
4 years ago