diff --git a/lib/index.js b/lib/index.js index 79ac789..1098c80 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,15 +2,16 @@ import readCache from './read-cache' import serialize from './serialize' +import memoryStore from './memory' function cache (config = {}) { - if (!config.store) { + const store = config.store || memoryStore + const key = config.key || cache.key + + if (!store) { throw new Error('Cache middleware need to be provided a store.') } - const store = config.store - const key = config.key || cache.key - config.maxAge = config.maxAge || 0 config.readCache = config.readCache || readCache config.serialize = config.serialize || serialize