bump hashicorp/golang-lru v0.5.3
full diff: https://github.com/hashicorp/golang-lru/compare/v0.5.1...v0.5.3 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ed1df65c25
commit
55f737bd32
@ -44,7 +44,7 @@ github.com/google/go-cmp v0.2.0
|
|||||||
go.etcd.io/bbolt v1.3.3
|
go.etcd.io/bbolt v1.3.3
|
||||||
github.com/hashicorp/errwrap v1.0.0
|
github.com/hashicorp/errwrap v1.0.0
|
||||||
github.com/hashicorp/go-multierror v1.0.0
|
github.com/hashicorp/go-multierror v1.0.0
|
||||||
github.com/hashicorp/golang-lru v0.5.1
|
github.com/hashicorp/golang-lru v0.5.3
|
||||||
go.opencensus.io v0.22.0
|
go.opencensus.io v0.22.0
|
||||||
|
|
||||||
# cri dependencies
|
# cri dependencies
|
||||||
|
2
vendor/github.com/hashicorp/golang-lru/go.mod
generated
vendored
2
vendor/github.com/hashicorp/golang-lru/go.mod
generated
vendored
@ -1 +1,3 @@
|
|||||||
module github.com/hashicorp/golang-lru
|
module github.com/hashicorp/golang-lru
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
16
vendor/github.com/hashicorp/golang-lru/simplelru/lru.go
generated
vendored
16
vendor/github.com/hashicorp/golang-lru/simplelru/lru.go
generated
vendored
@ -73,6 +73,9 @@ func (c *LRU) Add(key, value interface{}) (evicted bool) {
|
|||||||
func (c *LRU) Get(key interface{}) (value interface{}, ok bool) {
|
func (c *LRU) Get(key interface{}) (value interface{}, ok bool) {
|
||||||
if ent, ok := c.items[key]; ok {
|
if ent, ok := c.items[key]; ok {
|
||||||
c.evictList.MoveToFront(ent)
|
c.evictList.MoveToFront(ent)
|
||||||
|
if ent.Value.(*entry) == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
return ent.Value.(*entry).value, true
|
return ent.Value.(*entry).value, true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -142,6 +145,19 @@ func (c *LRU) Len() int {
|
|||||||
return c.evictList.Len()
|
return c.evictList.Len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resize changes the cache size.
|
||||||
|
func (c *LRU) Resize(size int) (evicted int) {
|
||||||
|
diff := c.Len() - size
|
||||||
|
if diff < 0 {
|
||||||
|
diff = 0
|
||||||
|
}
|
||||||
|
for i := 0; i < diff; i++ {
|
||||||
|
c.removeOldest()
|
||||||
|
}
|
||||||
|
c.size = size
|
||||||
|
return diff
|
||||||
|
}
|
||||||
|
|
||||||
// removeOldest removes the oldest item from the cache.
|
// removeOldest removes the oldest item from the cache.
|
||||||
func (c *LRU) removeOldest() {
|
func (c *LRU) removeOldest() {
|
||||||
ent := c.evictList.Back()
|
ent := c.evictList.Back()
|
||||||
|
7
vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go
generated
vendored
7
vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go
generated
vendored
@ -10,7 +10,7 @@ type LRUCache interface {
|
|||||||
// updates the "recently used"-ness of the key. #value, isFound
|
// updates the "recently used"-ness of the key. #value, isFound
|
||||||
Get(key interface{}) (value interface{}, ok bool)
|
Get(key interface{}) (value interface{}, ok bool)
|
||||||
|
|
||||||
// Check if a key exsists in cache without updating the recent-ness.
|
// Checks if a key exists in cache without updating the recent-ness.
|
||||||
Contains(key interface{}) (ok bool)
|
Contains(key interface{}) (ok bool)
|
||||||
|
|
||||||
// Returns key's value without updating the "recently used"-ness of the key.
|
// Returns key's value without updating the "recently used"-ness of the key.
|
||||||
@ -31,6 +31,9 @@ type LRUCache interface {
|
|||||||
// Returns the number of items in the cache.
|
// Returns the number of items in the cache.
|
||||||
Len() int
|
Len() int
|
||||||
|
|
||||||
// Clear all cache entries
|
// Clears all cache entries.
|
||||||
Purge()
|
Purge()
|
||||||
|
|
||||||
|
// Resizes cache, returning number evicted
|
||||||
|
Resize(int) int
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user