Http: when caching allow single inflight GET request only (#22959)
This commit is contained in:
parent
3c11886d35
commit
ceb55dcae6
2 changed files with 33 additions and 0 deletions
21
plugin/http_limit.go
Normal file
21
plugin/http_limit.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package plugin
|
||||
|
||||
import "sync"
|
||||
|
||||
var (
|
||||
httpMu sync.Mutex
|
||||
httpMutexes = map[string]*sync.Mutex{}
|
||||
)
|
||||
|
||||
func muForKey(key string) *sync.Mutex {
|
||||
httpMu.Lock()
|
||||
defer httpMu.Unlock()
|
||||
|
||||
if mu, ok := httpMutexes[key]; ok {
|
||||
return mu
|
||||
}
|
||||
|
||||
mu := new(sync.Mutex)
|
||||
httpMutexes[key] = mu
|
||||
return mu
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue