@@ -49,7 +49,7 @@ func (con indexController) Open(c *gin.Context) {
4949 con .Error (c , err .Error ())
5050 return
5151 }
52- global .GlobalClients [ keys [1 ]] = client
52+ global .SetClient ( keys [1 ], client )
5353 global .GlobalConf .RedisServices .Store (keys [1 ], redisServer )
5454
5555 val , _ := c .Get ("username" )
@@ -124,7 +124,7 @@ func (con indexController) GetKeys(c *gin.Context) {
124124
125125 dbInfo := strings .Split (req .Index , "-" )
126126 index , _ := strconv .Atoi (dbInfo [0 ])
127- client := global .GlobalClients [ dbInfo [1 ]]
127+ client := global .GetClient ( dbInfo [1 ])
128128
129129 val , _ := c .Get ("username" )
130130 ctx := context .WithValue (context .Background (), "username" , val )
@@ -188,7 +188,7 @@ func (con indexController) GetKeyType(c *gin.Context) {
188188 return
189189 }
190190
191- client := global .GlobalClients [ req .Sk ]
191+ client := global .GetClient ( req .Sk )
192192
193193 val , _ := c .Get ("username" )
194194 ctx := context .WithValue (context .Background (), "username" , val )
@@ -221,7 +221,7 @@ func (con indexController) DelKey(c *gin.Context) {
221221 return
222222 }
223223
224- client := global .GlobalClients [ req .Sk ]
224+ client := global .GetClient ( req .Sk )
225225
226226 val , _ := c .Get ("username" )
227227 ctx := context .WithValue (context .Background (), "username" , val )
@@ -263,7 +263,7 @@ func (con indexController) TtlKey(c *gin.Context) {
263263 return
264264 }
265265
266- client := global .GlobalClients [ req .Sk ]
266+ client := global .GetClient ( req .Sk )
267267
268268 val , _ := c .Get ("username" )
269269 ctx := context .WithValue (context .Background (), "username" , val )
@@ -293,7 +293,6 @@ func (con indexController) TtlKey(c *gin.Context) {
293293func (con indexController ) SerInfo (c * gin.Context ) {
294294 var req model.InfoReq
295295 var client * redis.Client
296- var ok bool
297296
298297 err := con .FormBind (c , & req )
299298 if err != nil {
@@ -304,14 +303,14 @@ func (con indexController) SerInfo(c *gin.Context) {
304303 redisServer , _ := global .GlobalConf .RedisServices .Load (req .Key )
305304 redisServers := redisServer .(global.RedisService )
306305
307- client , ok = global .GlobalClients [ req .Key ]
308- if ! ok {
306+ client = global .GetClient ( req .Key )
307+ if client == nil {
309308 client , err = service .NewRedisClient (redisServers )
310309 if err != nil {
311310 con .Error (c , err .Error ())
312311 return
313312 }
314- global .GlobalClients [ req .Key ] = client
313+ global .SetClient ( req .Key , client )
315314 }
316315
317316 val , _ := c .Get ("username" )
@@ -341,7 +340,7 @@ func (con indexController) LuaRun(c *gin.Context) {
341340 return
342341 }
343342
344- client := global .GlobalClients [ req .Sk ]
343+ client := global .GetClient ( req .Sk )
345344
346345 val , _ := c .Get ("username" )
347346 ctx := context .WithValue (context .Background (), "username" , val )
0 commit comments