Skip to content

Commit 0042cf6

Browse files
committed
Rewrite test suite and fix skipArgs in warmup/invalidate
- Rewrote test suite with proper isolation using beforeEach - Expanded from 11 to 22 tests covering all features - Added tests for invalidate(), isReady(), skipArgs, LRU eviction, error handling - Fixed skipArgs: store on cached function and retrieve via func.skipArgs in warmup/invalidate instead of misleading parameter name
1 parent 25d540b commit 0042cf6

2 files changed

Lines changed: 321 additions & 99 deletions

File tree

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,30 @@ var cache = {
150150

151151
log('created cache function %s', fname);
152152
cachedfunc.cacheName = fname;
153+
cachedfunc.skipArgs = skipArgs;
153154
return cachedfunc;
154155
};
155156

156-
this.warmup = function(skipArgs) {
157+
this.warmup = function() {
157158
var args = Array.prototype.slice.apply(arguments);
158159
var func = args.shift();
159160
var res = args.pop();
160161

161162
validateCacheFunction(func);
162163

163-
var keyArgs = filterArgs(args, skipArgs);
164+
var keyArgs = filterArgs(args, func.skipArgs);
164165
var key = keygen(func.cacheName, keyArgs);
165166
log('warming cache %s key %s', func.cacheName, key);
166167
store.set(key, res);
167168
};
168169

169-
this.invalidate = function(skipArgs) {
170+
this.invalidate = function() {
170171
var args = Array.prototype.slice.apply(arguments);
171172
var func = args.shift();
172173

173174
validateCacheFunction(func);
174175

175-
var keyArgs = filterArgs(args, skipArgs);
176+
var keyArgs = filterArgs(args, func.skipArgs);
176177
var key = keygen(func.cacheName, keyArgs);
177178
log('invalidating %s key %s', func.cacheName, key);
178179
store.expire(key);

0 commit comments

Comments
 (0)