浏览代码

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>
Sebastiaan van Stijn 5 年之前
父节点
当前提交
82097c0f1f

+ 1 - 1
vendor.conf

@@ -138,7 +138,7 @@ golang.org/x/crypto                                 88737f569e3a9c7ab309cdc09a07
 golang.org/x/time                                   fbb02b2291d28baffd63558aa44b4b56f178d650
 golang.org/x/time                                   fbb02b2291d28baffd63558aa44b4b56f178d650
 github.com/hashicorp/go-memdb                       cb9a474f84cc5e41b273b20c6927680b2a8776ad
 github.com/hashicorp/go-memdb                       cb9a474f84cc5e41b273b20c6927680b2a8776ad
 github.com/hashicorp/go-immutable-radix             826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git
 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
 github.com/coreos/pkg                               3ac0863d7acf3bc44daf49afef8919af12f704ef # v3
 code.cloudfoundry.org/clock                         02e53af36e6c978af692887ed449b74026d76fec
 code.cloudfoundry.org/clock                         02e53af36e6c978af692887ed449b74026d76fec
 
 

+ 2 - 0
vendor/github.com/hashicorp/golang-lru/go.mod

@@ -1 +1,3 @@
 module github.com/hashicorp/golang-lru
 module github.com/hashicorp/golang-lru
+
+go 1.12

+ 16 - 0
vendor/github.com/hashicorp/golang-lru/simplelru/lru.go

@@ -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()

+ 5 - 2
vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go

@@ -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
 }
 }