Skip to content

Commit

Permalink
Merge branch 'release/0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrister committed Sep 8, 2016
2 parents 20c91ac + ad6754c commit 8f18b34
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 96 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,8 @@ function redisStore(args) {
}

if (opts.parse) {

try {
// allow undefined only if allowed by isCacheableValue
if(! ( (result === undefined || result === 'undefined') && typeof args.isCacheableValue === 'function' && args.isCacheableValue(result))) {
result = JSON.parse(result);
}
result = JSON.parse(result);
} catch (e) {
return cb && cb(e);
}
Expand Down Expand Up @@ -129,7 +125,8 @@ function redisStore(args) {
}

/**
* Apply some options like hostname , port, db, ttl auth_pass from options to newArgs host, port, db, auth_pass and ttl and return clone of args
* Apply some options like hostname, port, db, ttl, auth_pass, password
* from options to newArgs host, port, db, auth_pass, password and ttl and return clone of args
* @param {Object} args
* @param {Object} options
* @returns {Object} clone of args param with properties set to those of options
Expand All @@ -140,6 +137,7 @@ function redisStore(args) {
newArgs.port = parseInt(options.port, 10);
newArgs.db = parseInt(options.database, 10);
newArgs.auth_pass = options.password;
newArgs.password = options.password;
if(options.query && options.query.ttl){
newArgs.ttl = parseInt(options.query.ttl, 10);
}
Expand Down Expand Up @@ -185,6 +183,10 @@ function redisStore(args) {
options = {};
}

if (!self.isCacheableValue(value)) {
return cb(new Error('value cannot be ' + value));
}

options = options || {};

var ttl = (options.ttl || options.ttl === 0) ? options.ttl : redisOptions.ttl;
Expand All @@ -193,7 +195,7 @@ function redisStore(args) {
if (err) {
return cb && cb(err);
}
var val = JSON.stringify(value);
var val = JSON.stringify(value) || '"undefined"';
if (ttl) {
conn.setex(key, ttl, val, handleResponse(conn, cb));
} else {
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "cache-manager-redis",
"version": "0.2.3",
"version": "0.2.4",
"description": "Redis store for the node-cache-manager",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/jasmine",
"coverage": "node_modules/.bin/istanbul cover node_modules/.bin/jasmine",
"test": "node_modules/.bin/mocha --recursive test",
"coverage": "node_modules/.bin/istanbul cover _mocha -- test --recursive",
"lint": "node_modules/.bin/jshint .",
"jsdoc": "node_modules/.bin/jsdoc . --package package.json --readme README.md --template node_modules/minami --destination docs"
},
Expand All @@ -24,15 +24,14 @@
"dependencies": {
"cache-manager": "^1.2.2",
"redis-url": "^1.2.1",
"sol-redis-pool": "^0.2.1"
"sol-redis-pool": "^0.3.1"
},
"devDependencies": {
"codacy-coverage": "^1.1.3",
"istanbul": "^0.4.0",
"jasmine": "^2.3.2",
"jsdoc": "^3.3.3",
"jshint": "^2.8.0",
"minami": "^1.1.1",
"mocha": "^3.0.2",
"sinon": "^1.17.2"
}
}
6 changes: 0 additions & 6 deletions spec/support/jasmine.json

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 8f18b34

Please sign in to comment.