cachier
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -32,2 +32,3 @@ var oh = require('object-hash'); | ||
var self = this; | ||
var originalKey = key; | ||
@@ -48,3 +49,3 @@ if (typeof key !== 'string') { | ||
//call fn to get the data and then cache it. | ||
fn(key, function (err, data) { | ||
fn(originalKey, function (err, data) { | ||
//don't set anything if there was an error | ||
@@ -51,0 +52,0 @@ if (err) { |
{ | ||
"name": "cachier", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Caching with various backends", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
45
test.js
@@ -10,2 +10,3 @@ var test = require('tape'); | ||
, function getUncached (key, cb) { | ||
t.equal(key, 'a'); | ||
return cb(null, "some value for the key") | ||
@@ -27,2 +28,3 @@ } | ||
, function getUncached (key, cb) { | ||
t.equal(key, 'a'); | ||
return cb(new Error('this is the error')) | ||
@@ -46,2 +48,3 @@ } | ||
, function getUncached (key, cb) { | ||
t.equal(key, 'a'); | ||
return cb(null, "some value for the key") | ||
@@ -64,2 +67,4 @@ } | ||
var lookup = c.functionize(function (key, cb) { | ||
t.equal(key, 'a'); | ||
return cb(null, "this is the value of " + key); | ||
@@ -76,1 +81,41 @@ }); | ||
}); | ||
test('Object Key MemStore Usage', function (t) { | ||
var c = new Cachier(); | ||
var ukey = { object_id : 1234 }; | ||
c.get(ukey | ||
, function getUncached (key, cb) { | ||
t.equal(key, ukey); | ||
return cb(null, "some value for the key") | ||
} | ||
, function done(err, data) { | ||
t.equals(data, "some value for the key") | ||
c.end(function (e) { | ||
t.end(); | ||
}); | ||
}); | ||
}); | ||
test('Object Key RedisStore Usage', function (t) { | ||
var c = new Cachier({ | ||
store : new Cachier.RedisStore(redis.createClient()) | ||
}); | ||
var ukey = { object_id : 1234 }; | ||
c.get(ukey | ||
, function getUncached (key, cb) { | ||
t.equal(key, ukey); | ||
return cb(null, "some value for the key") | ||
} | ||
, function done(err, data) { | ||
t.equals(data, "some value for the key") | ||
c.end(function (e) { | ||
t.end(); | ||
}); | ||
}); | ||
}); |
14745
533