open-consul/agent/consul/authmethod/authmethods_oss.go
R.B. Boyer 83bf7ab3ff
re-run gofmt on 1.17 (#11579)
This should let freshly recompiled golangci-lint binaries using Go 1.17
pass 'make lint'
2021-11-16 12:04:01 -06:00

40 lines
748 B
Go

//go:build !consulent
// +build !consulent
package authmethod
import (
"sync"
"github.com/hashicorp/consul/agent/structs"
)
type syncCache struct {
lock sync.RWMutex
cache authMethodCache
}
func NewCache() Cache {
c := &syncCache{}
c.cache.init()
return c
}
func (c *syncCache) GetValidator(method *structs.ACLAuthMethod) (uint64, Validator, bool) {
c.lock.RLock()
defer c.lock.RUnlock()
return c.cache.GetValidator(method)
}
func (c *syncCache) PutValidatorIfNewer(method *structs.ACLAuthMethod, validator Validator, idx uint64) Validator {
c.lock.Lock()
defer c.lock.Unlock()
return c.cache.PutValidatorIfNewer(method, validator, idx)
}
func (c *syncCache) Purge() {
c.lock.Lock()
defer c.lock.Unlock()
c.cache.Purge()
}