@@ -7,8 +7,10 @@ const redisStore = (...args) => {
77 return {
88 name : 'redis' ,
99 getClient : ( ) => redisCache ,
10- set : ( key , value , options , cb ) => (
11- new Promise ( ( resolve , reject ) => {
10+ set : function ( key , value , options , cb ) {
11+ const self = this ;
12+
13+ return new Promise ( ( resolve , reject ) => {
1214 if ( typeof options === 'function' ) {
1315 cb = options ;
1416 options = { } ;
@@ -19,6 +21,10 @@ const redisStore = (...args) => {
1921 cb = ( err , result ) => ( err ? reject ( err ) : resolve ( result ) ) ;
2022 }
2123
24+ if ( ! self . isCacheableValue ( value ) ) {
25+ return cb ( new Error ( `"${ value } " is not a cacheable value` ) ) ;
26+ }
27+
2228 const ttl = ( options . ttl || options . ttl === 0 ) ? options . ttl : storeArgs . ttl ;
2329 const val = JSON . stringify ( value ) || '"undefined"' ;
2430
@@ -28,9 +34,9 @@ const redisStore = (...args) => {
2834 redisCache . set ( key , val , handleResponse ( cb ) ) ;
2935 }
3036 } )
31- ) ,
37+ } ,
3238 mset : function ( ...args ) {
33- const _this = this ;
39+ const self = this ;
3440
3541 return new Promise ( ( resolve , reject ) => {
3642 let cb ;
@@ -65,8 +71,8 @@ const redisStore = (...args) => {
6571 /**
6672 * Make sure the value is cacheable
6773 */
68- if ( ! _this . isCacheableValue ( value ) ) {
69- return cb ( new Error ( `value cannot be ${ value } ` ) ) ;
74+ if ( ! self . isCacheableValue ( value ) ) {
75+ return cb ( new Error ( `" ${ value } " is not a cacheable value` ) ) ;
7076 }
7177
7278 value = JSON . stringify ( value ) || '"undefined"' ;
0 commit comments