@@ -72,12 +72,8 @@ function redisStore(args) {
7272 }
7373
7474 if ( opts . parse ) {
75-
7675 try {
77- // allow undefined only if allowed by isCacheableValue
78- if ( ! ( ( result === undefined || result === 'undefined' ) && typeof args . isCacheableValue === 'function' && args . isCacheableValue ( result ) ) ) {
79- result = JSON . parse ( result ) ;
80- }
76+ result = JSON . parse ( result ) ;
8177 } catch ( e ) {
8278 return cb && cb ( e ) ;
8379 }
@@ -129,7 +125,8 @@ function redisStore(args) {
129125 }
130126
131127 /**
132- * 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
128+ * Apply some options like hostname, port, db, ttl, auth_pass, password
129+ * from options to newArgs host, port, db, auth_pass, password and ttl and return clone of args
133130 * @param {Object } args
134131 * @param {Object } options
135132 * @returns {Object } clone of args param with properties set to those of options
@@ -140,6 +137,7 @@ function redisStore(args) {
140137 newArgs . port = parseInt ( options . port , 10 ) ;
141138 newArgs . db = parseInt ( options . database , 10 ) ;
142139 newArgs . auth_pass = options . password ;
140+ newArgs . password = options . password ;
143141 if ( options . query && options . query . ttl ) {
144142 newArgs . ttl = parseInt ( options . query . ttl , 10 ) ;
145143 }
@@ -185,6 +183,10 @@ function redisStore(args) {
185183 options = { } ;
186184 }
187185
186+ if ( ! self . isCacheableValue ( value ) ) {
187+ return cb ( new Error ( 'value cannot be ' + value ) ) ;
188+ }
189+
188190 options = options || { } ;
189191
190192 var ttl = ( options . ttl || options . ttl === 0 ) ? options . ttl : redisOptions . ttl ;
@@ -193,7 +195,7 @@ function redisStore(args) {
193195 if ( err ) {
194196 return cb && cb ( err ) ;
195197 }
196- var val = JSON . stringify ( value ) ;
198+ var val = JSON . stringify ( value ) || '"undefined"' ;
197199 if ( ttl ) {
198200 conn . setex ( key , ttl , val , handleResponse ( conn , cb ) ) ;
199201 } else {
0 commit comments