mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
LRUExpireCache#Get requires write lock
This commit is contained in:
parent
dc529a03b1
commit
0bd475676b
6
pkg/util/cache/lruexpirecache.go
vendored
6
pkg/util/cache/lruexpirecache.go
vendored
@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
type LRUExpireCache struct {
|
type LRUExpireCache struct {
|
||||||
cache *lru.Cache
|
cache *lru.Cache
|
||||||
lock sync.RWMutex
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLRUExpireCache(maxSize int) *LRUExpireCache {
|
func NewLRUExpireCache(maxSize int) *LRUExpireCache {
|
||||||
@ -46,8 +46,8 @@ func (c *LRUExpireCache) Add(key lru.Key, value interface{}, ttl time.Duration)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *LRUExpireCache) Get(key lru.Key) (interface{}, bool) {
|
func (c *LRUExpireCache) Get(key lru.Key) (interface{}, bool) {
|
||||||
c.lock.RLock()
|
c.lock.Lock()
|
||||||
defer c.lock.RUnlock()
|
defer c.lock.Unlock()
|
||||||
e, ok := c.cache.Get(key)
|
e, ok := c.cache.Get(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, false
|
return nil, false
|
||||||
|
Loading…
Reference in New Issue
Block a user