route-cache
Advanced tools
Comparing version 0.2.8 to 0.3.0
14
index.js
'use strict' | ||
var Eidetic = require('eidetic') | ||
var cacheStore = new Eidetic({ | ||
maxSize: 50, | ||
canPutWhenFull: true | ||
var LRU = require('lru-cache') | ||
var cacheStore = new LRU({ | ||
maxSize: 500, | ||
maxAge: 30 | ||
}) | ||
@@ -11,3 +11,5 @@ | ||
module.exports.cacheSeconds = function (ttl) { | ||
module.exports.cacheSeconds = function (secondsTTL) { | ||
var ttl = secondsTTL * 1000 | ||
return function (req, res, next) { | ||
@@ -56,3 +58,3 @@ var key = req.originalUrl | ||
var body = data instanceof Buffer ? data.toString() : data | ||
if (res.statusCode < 400) cacheStore.put(key, { body: body, isJson: isJson }, ttl) | ||
if (res.statusCode < 400) cacheStore.set(key, { body: body, isJson: isJson }, ttl) | ||
@@ -59,0 +61,0 @@ // drain the queue so anyone else waiting for |
@@ -7,3 +7,3 @@ // app.js | ||
var CACHE_TTL = 20 | ||
var HIT_CNT = 0 // for debugging back-pressure valve | ||
var HIT_CNT = 1 // for debugging back-pressure valve | ||
@@ -10,0 +10,0 @@ if (process.argv[3]) { |
{ | ||
"name": "route-cache", | ||
"version": "0.2.8", | ||
"version": "0.3.0", | ||
"description": "express middleware for caching your routes", | ||
@@ -22,3 +22,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"eidetic": "^0.3.1" | ||
"lru-cache": "4.0.1" | ||
}, | ||
@@ -25,0 +25,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25038
637
1
+ Addedlru-cache@4.0.1
+ Addedlru-cache@4.0.1(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedeidetic@^0.3.1
- Removedclone@0.2.0(transitive)
- Removedeidetic@0.3.1(transitive)