mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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
bc5484d2dd
commit
82097c0f1f
4 changed files with 24 additions and 3 deletions
|
@ -138,7 +138,7 @@ golang.org/x/crypto 88737f569e3a9c7ab309cdc09a07
|
|||
golang.org/x/time fbb02b2291d28baffd63558aa44b4b56f178d650
|
||||
github.com/hashicorp/go-memdb cb9a474f84cc5e41b273b20c6927680b2a8776ad
|
||||
github.com/hashicorp/go-immutable-radix 826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git
|
||||
github.com/hashicorp/golang-lru 7087cb70de9f7a8bc0a10c375cb0d2280a8edf9c # v0.5.1
|
||||
github.com/hashicorp/golang-lru 7f827b33c0f158ec5dfbba01bb0b14a4541fd81d # v0.5.3
|
||||
github.com/coreos/pkg 3ac0863d7acf3bc44daf49afef8919af12f704ef # v3
|
||||
code.cloudfoundry.org/clock 02e53af36e6c978af692887ed449b74026d76fec
|
||||
|
||||
|
|
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
|
||||
|
||||
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) {
|
||||
if ent, ok := c.items[key]; ok {
|
||||
c.evictList.MoveToFront(ent)
|
||||
if ent.Value.(*entry) == nil {
|
||||
return nil, false
|
||||
}
|
||||
return ent.Value.(*entry).value, true
|
||||
}
|
||||
return
|
||||
|
@ -142,6 +145,19 @@ func (c *LRU) Len() int {
|
|||
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.
|
||||
func (c *LRU) removeOldest() {
|
||||
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
|
||||
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)
|
||||
|
||||
// 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.
|
||||
Len() int
|
||||
|
||||
// Clear all cache entries
|
||||
// Clears all cache entries.
|
||||
Purge()
|
||||
|
||||
// Resizes cache, returning number evicted
|
||||
Resize(int) int
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue