Skip to content

Commit 6731626

Browse files
mcollinajsumners
authored andcommitted
use a plugin-level cache (#13)
* use a plugin-level cache * cache: undefined
1 parent d13781f commit 6731626

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plugin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
const fp = require('fastify-plugin')
44
const uidSafe = require('uid-safe')
5+
const abstractCache = require('abstract-cache')
6+
57
const defaultOptions = {
68
expiresIn: undefined,
79
privacy: undefined,
8-
cache: require('abstract-cache')(),
10+
cache: undefined,
911
cacheSegment: 'fastify-caching'
1012
}
1113

@@ -57,7 +59,7 @@ function fastifyCachingPlugin (instance, options, next) {
5759
_options = Object.assign({}, defaultOptions, options)
5860
}
5961

60-
if (!_options.cache) _options.cache = defaultOptions.cache
62+
if (!_options.cache) _options.cache = abstractCache()
6163

6264
if (_options.privacy) {
6365
// https://tools.ietf.org/html/rfc2616#section-14.9.4

0 commit comments

Comments
 (0)