@@ -4,64 +4,84 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
44
55var Redis = _interopDefault ( require ( 'redis' ) ) ;
66
7- const redisStore = ( ...args ) => {
8- const redisCache = Redis . createClient ( ...args ) ;
9- const storeArgs = redisCache . options ;
7+ var redisStore = function redisStore ( ) {
8+ for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
9+ args [ _key ] = arguments [ _key ] ;
10+ }
11+
12+ var redisCache = Redis . createClient . apply ( Redis , args ) ;
13+ var storeArgs = redisCache . options ;
1014
1115 return {
1216 name : 'redis' ,
13- getClient : ( ) => redisCache ,
14- set : ( key , value , options , cb ) => (
15- new Promise ( ( resolve , reject ) => {
17+ getClient : function getClient ( ) {
18+ return redisCache ;
19+ } ,
20+ set : function set ( key , value , options , cb ) {
21+ return new Promise ( function ( resolve , reject ) {
1622 if ( typeof options === 'function' ) {
1723 cb = options ;
1824 options = { } ;
1925 }
2026 options = options || { } ;
2127
2228 if ( ! cb ) {
23- cb = ( err , result ) => ( err ? reject ( err ) : resolve ( result ) ) ;
29+ cb = function cb ( err , result ) {
30+ return err ? reject ( err ) : resolve ( result ) ;
31+ } ;
2432 }
2533
26- const ttl = ( options . ttl || options . ttl === 0 ) ? options . ttl : storeArgs . ttl ;
27- const val = JSON . stringify ( value ) || '"undefined"' ;
34+ var ttl = options . ttl || options . ttl === 0 ? options . ttl : storeArgs . ttl ;
35+ var val = JSON . stringify ( value ) || '"undefined"' ;
2836
2937 if ( ttl ) {
3038 redisCache . setex ( key , ttl , val , handleResponse ( cb ) ) ;
3139 } else {
3240 redisCache . set ( key , val , handleResponse ( cb ) ) ;
3341 }
34- } )
35- ) ,
36- get : ( key , options , cb ) => (
37- new Promise ( ( resolve , reject ) => {
42+ } ) ;
43+ } ,
44+ get : function get ( key , options , cb ) {
45+ return new Promise ( function ( resolve , reject ) {
3846 if ( typeof options === 'function' ) {
3947 cb = options ;
4048 }
4149
4250 if ( ! cb ) {
43- cb = ( err , result ) => ( err ? reject ( err ) : resolve ( result ) ) ;
51+ cb = function cb ( err , result ) {
52+ return err ? reject ( err ) : resolve ( result ) ;
53+ } ;
4454 }
4555
4656 redisCache . get ( key , handleResponse ( cb , { parse : true } ) ) ;
47- } )
48- ) ,
49- del : ( key , options , cb ) => {
57+ } ) ;
58+ } ,
59+ del : function del ( key , options , cb ) {
5060 if ( typeof options === 'function' ) {
5161 cb = options ;
5262 }
5363
5464 redisCache . del ( key , handleResponse ( cb ) ) ;
5565 } ,
56- reset : cb => redisCache . flushdb ( handleResponse ( cb ) ) ,
57- keys : cb => redisCache . keys ( handleResponse ( cb ) ) ,
58- ttl : ( key , cb ) => redisCache . ttl ( key , handleResponse ( cb ) ) ,
59- isCacheableValue : args . isCacheableValue || ( value => value !== undefined && value !== null ) ,
66+ reset : function reset ( cb ) {
67+ return redisCache . flushdb ( handleResponse ( cb ) ) ;
68+ } ,
69+ keys : function keys ( cb ) {
70+ return redisCache . keys ( handleResponse ( cb ) ) ;
71+ } ,
72+ ttl : function ttl ( key , cb ) {
73+ return redisCache . ttl ( key , handleResponse ( cb ) ) ;
74+ } ,
75+ isCacheableValue : args . isCacheableValue || function ( value ) {
76+ return value !== undefined && value !== null ;
77+ }
6078 } ;
6179} ;
6280
63- function handleResponse ( cb , opts = { } ) {
64- return ( err , result ) => {
81+ function handleResponse ( cb ) {
82+ var opts = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
83+
84+ return function ( err , result ) {
6585 if ( err ) {
6686 return cb && cb ( err ) ;
6787 }
@@ -78,8 +98,10 @@ function handleResponse(cb, opts = {}) {
7898 } ;
7999}
80100
81- const methods = {
82- create : ( ...args ) => redisStore ( ...args ) ,
101+ var methods = {
102+ create : function create ( ) {
103+ return redisStore . apply ( undefined , arguments ) ;
104+ }
83105} ;
84106
85107module . exports = methods ;
0 commit comments