Commit bcdd15b 1 parent 8adf4d8 commit bcdd15b Copy full SHA for bcdd15b
File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -236,15 +236,21 @@ func (p *Plugin) shutdown() {
236
236
}
237
237
238
238
func (p * Plugin ) ensureConnectionCache (connectionName string ) (* connectionmanager.ConnectionCache , error ) {
239
+ p .connectionCacheMapLock .Lock ()
240
+ defer p .connectionCacheMapLock .Unlock ()
241
+
242
+ // check if we already have a cache
243
+ if cache , ok := p .connectionCacheMap [connectionName ]; ok {
244
+ return cache , nil
245
+ }
246
+
247
+ // add to map of connection caches
239
248
maxCost := int64 (100000 / len (p .ConnectionMap ))
240
249
connectionCache , err := connectionmanager .NewConnectionCache (connectionName , maxCost )
241
250
if err != nil {
242
251
return nil , err
243
252
}
244
253
245
- p .connectionCacheMapLock .Lock ()
246
- defer p .connectionCacheMapLock .Unlock ()
247
- // add to map of connection caches
248
254
p .connectionCacheMap [connectionName ] = connectionCache
249
255
return connectionCache , nil
250
256
}
You can’t perform that action at this time.
0 commit comments