route-cache
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -70,2 +70,10 @@ var Eidetic = require('eidetic'); | ||
module.exports.removeCache = function(url) { | ||
if (redirects[url]) | ||
delete redirects[url]; | ||
cacheStore.del(url); | ||
}; | ||
module.exports.cacheStore = cacheStore; |
{ | ||
"name": "route-cache", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "express middleware for caching your routes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,6 +0,7 @@ | ||
[![Build Status](https://travis-ci.org/bradoyler/route-cache.svg?branch=master)](https://travis-ci.org/bradoyler/route-cache) | ||
# Route-Cache | ||
Simple middleware for Express route caching with a given TTL (in seconds) | ||
[![Build Status](https://travis-ci.org/bradoyler/route-cache.svg?branch=master)](https://travis-ci.org/bradoyler/route-cache) | ||
[![NPM Version][npm-image]][npm-url] | ||
Make your routes do this ->![dodging](http://gifs.gifbin.com/1234778873_Muhammad_Ali_dodging_punches.gif) | ||
@@ -38,2 +39,7 @@ | ||
## Delete a cached route | ||
```javascript | ||
routeCache.removeCache('/index'); | ||
``` | ||
## Future plans / todos | ||
@@ -65,1 +71,4 @@ - client-side Cache-Control | ||
SOFTWARE. | ||
[npm-image]: https://img.shields.io/npm/v/route-cache.svg | ||
[npm-url]: https://npmjs.org/package/route-cache |
@@ -9,2 +9,3 @@ | ||
var testindex = 0; | ||
var testindexRemove = 0; | ||
@@ -15,3 +16,3 @@ describe('# RouteCache middleware test', function(){ | ||
app.get('/hello', routeCache.cacheSeconds(1), function(req, res){ | ||
testindex++; | ||
testindex++; | ||
res.send('Hello ' + testindex) | ||
@@ -28,2 +29,7 @@ }); | ||
app.get('/hello-remove', routeCache.cacheSeconds(3600), function(req, res){ | ||
testindexRemove++; | ||
res.send('Hello remove ' + testindexRemove) | ||
}); | ||
var agent = request.agent(app); | ||
@@ -62,6 +68,6 @@ | ||
it('GET #6 ~ delayed: Hello 2', function(done){ | ||
setTimeout(function() { | ||
agent | ||
.get('/hello') | ||
.expect('Hello 2', done); | ||
setTimeout(function() { | ||
agent | ||
.get('/hello') | ||
.expect('Hello 2', done); | ||
}, 1200); | ||
@@ -81,3 +87,26 @@ }); | ||
}) | ||
}) | ||
}); | ||
it('GET #8: test removeCache', function(done){ | ||
agent | ||
.get('/hello-remove') | ||
.expect('Hello remove 1').end(function(req, res){ | ||
setTimeout(function() { | ||
agent | ||
.get('/hello-remove') | ||
.expect('Hello remove 1').end(function(req, res){ | ||
routeCache.removeCache('/hello-remove'); | ||
agent | ||
.get('/hello-remove') | ||
.expect('Hello remove 2', done) | ||
}); | ||
}, 1200); | ||
}); | ||
}); | ||
}); |
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
7430
143
73