1
+ var log = require ( "winston" ) ;
1
2
var redis = require ( "redis" ) ;
2
3
3
4
var DEFAULT_HOST = "127.0.0.1" ;
@@ -58,6 +59,12 @@ function firstDefinedIndex (targets) {
58
59
return - 1 ;
59
60
}
60
61
62
+ function logErr ( err ) {
63
+ if ( err ) {
64
+ log . error ( "REDIS error:" , err ) ;
65
+ }
66
+ }
67
+
61
68
exports . create = function ( BaseStore , host , port , db ) {
62
69
var client = createClient ( host , port , db ) ;
63
70
@@ -67,6 +74,7 @@ exports.create = function (BaseStore, host, port, db) {
67
74
var that = this ;
68
75
69
76
client . hgetall ( path , function ( err , res ) {
77
+ logErr ( err ) ;
70
78
that . notify ( cb , expand ( res ) || undefined ) ;
71
79
} ) ;
72
80
}
@@ -81,6 +89,7 @@ exports.create = function (BaseStore, host, port, db) {
81
89
keys . forEach ( function ( key ) { multi . hgetall ( key ) ; } ) ;
82
90
83
91
multi . exec ( function ( err , values ) {
92
+ logErr ( err ) ;
84
93
if ( err || values . length === 0 ) {
85
94
that . notify ( cb ) ;
86
95
return ;
@@ -102,6 +111,7 @@ exports.create = function (BaseStore, host, port, db) {
102
111
var that = this ;
103
112
104
113
client . keys ( "*" , function ( err , keys ) {
114
+ logErr ( err ) ;
105
115
if ( err || keys . length === 0 ) {
106
116
that . notify ( cb , { } ) ;
107
117
return ;
@@ -114,6 +124,7 @@ exports.create = function (BaseStore, host, port, db) {
114
124
keys . forEach ( function ( key ) { multi . hgetall ( key ) ; } ) ;
115
125
116
126
multi . exec ( function ( err , values ) {
127
+ logErr ( err ) ;
117
128
keys . forEach ( function ( key , index ) {
118
129
routes [ key ] = expand ( values [ index ] ) ;
119
130
} ) ;
@@ -128,6 +139,7 @@ exports.create = function (BaseStore, host, port, db) {
128
139
var that = this ;
129
140
130
141
client . hmset ( path , scrub ( data ) , function ( err , res ) {
142
+ logErr ( err ) ;
131
143
that . notify ( cb ) ;
132
144
} ) ;
133
145
}
@@ -138,6 +150,7 @@ exports.create = function (BaseStore, host, port, db) {
138
150
139
151
this . get ( path , function ( current ) {
140
152
client . hmset ( path , Object . assign ( current , scrub ( data ) ) , function ( err , res ) {
153
+ logErr ( err ) ;
141
154
that . notify ( cb ) ;
142
155
} ) ;
143
156
} ) ;
@@ -148,6 +161,7 @@ exports.create = function (BaseStore, host, port, db) {
148
161
var that = this ;
149
162
150
163
client . del ( path , function ( err , res ) {
164
+ logErr ( err ) ;
151
165
that . notify ( cb ) ;
152
166
} ) ;
153
167
}
@@ -157,6 +171,7 @@ exports.create = function (BaseStore, host, port, db) {
157
171
var that = this ;
158
172
159
173
client . exists ( path , function ( err , res ) {
174
+ logErr ( err ) ;
160
175
that . notify ( cb , res === 1 ) ;
161
176
} ) ;
162
177
}
0 commit comments