cache-manager
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -113,2 +113,6 @@ /** | ||
self.isCacheableValue = function(value) { | ||
return value !== null && value !== undefined; | ||
}; | ||
return self; | ||
@@ -115,0 +119,0 @@ } |
@@ -0,1 +1,5 @@ | ||
- 1.1.0 2015-07-22 | ||
- Allow stores to override isCacheableValue. - @PuKoren | ||
- Allow overriding ttl in memory cache's set function. - @zhudan | ||
- 1.0.0 2015-05-23 | ||
@@ -2,0 +6,0 @@ - Added JSDOC generation (`make docs`) |
@@ -37,2 +37,4 @@ /** @module cacheManager/caching */ | ||
self._isCacheableValue = args.isCacheableValue; | ||
} else if (typeof self.store.isCacheableValue === 'function') { | ||
self._isCacheableValue = self.store.isCacheableValue; | ||
} else { | ||
@@ -39,0 +41,0 @@ self._isCacheableValue = function(value) { |
@@ -21,4 +21,9 @@ var Lru = require("lru-cache"); | ||
cb = options; | ||
options = {}; | ||
} | ||
lruCache.set(key, value); | ||
options = options || {}; | ||
var maxAge = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.maxAge; | ||
lruCache.set(key, value, maxAge); | ||
if (cb) { | ||
@@ -25,0 +30,0 @@ process.nextTick(cb); |
{ | ||
"name": "cache-manager", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Cache module for Node.js", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"async": "^0.9.0", | ||
"lru-cache": "^2.5.0" | ||
"lru-cache": "2.6.5" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
@@ -94,3 +94,3 @@ [![build status](https://secure.travis-ci.org/BryanDonovan/node-cache-manager.png)](http://travis-ci.org/BryanDonovan/node-cache-manager) | ||
memoryCache.set('foo', 'bar', ttl, function(err) { | ||
memoryCache.set('foo', 'bar', {ttl: ttl}, function(err) { | ||
if (err) { throw err; } | ||
@@ -118,3 +118,3 @@ | ||
getUser(userId, cb); | ||
}, ttl, function (err, user) { | ||
}, {ttl: ttl}, function (err, user) { | ||
console.log(user); | ||
@@ -169,4 +169,2 @@ | ||
var cache = cacheManager.caching({store: myStore}); | ||
// or | ||
var cache = cacheManager.caching({store: '/path/to/your/store'}); | ||
``` | ||
@@ -215,3 +213,3 @@ | ||
Both the `caching` and `multicaching` modules allow you to pass in a callback function called | ||
Both the `caching` and `multicaching` modules allow you to pass in a callback function named | ||
`isCacheableValue` which is called with every value returned from cache or from a wrapped function. | ||
@@ -249,3 +247,3 @@ This lets you specify which values should and should not be cached. If the function returns true, it will be | ||
## Docs | ||
## Docs | ||
@@ -270,3 +268,3 @@ To generate JSDOC 3 documentation: | ||
If you would like to contribute to the project, please fork it and send us a pull request. Please add tests | ||
for any new features or bug fixes. Also run ``make`` before submitting the pull request. | ||
for any new features or bug fixes. Also run `make` before submitting the pull request. | ||
@@ -273,0 +271,0 @@ |
@@ -710,2 +710,23 @@ // TODO: These are really a mix of unit and integration tests. | ||
}); | ||
describe("overloading with custom store", function() { | ||
it("allows us to override isCacheableValue", function(done) { | ||
var store = memoryStore.create({ttl: defaultTtl}); | ||
var onlyOne = true; | ||
store.isCacheableValue = function(result) { | ||
if (onlyOne) { | ||
onlyOne = false; | ||
done(); | ||
} | ||
return result !== undefined; | ||
}; | ||
cache = caching({store: store}); | ||
cache.wrap(key, function(cb) { | ||
methods.getWidget(name, cb); | ||
}, function(err, widget) { | ||
checkErr(err); | ||
assert.deepEqual(widget, {name: name}); | ||
}); | ||
}); | ||
}); | ||
}); |
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
112473
2390
269
+ Addedlru-cache@2.6.5(transitive)
- Removedlru-cache@2.7.3(transitive)
Updatedlru-cache@2.6.5