Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/NOTICE
diff options
context:
space:
mode:
authorGitLab Renovate Bot <gitlab-bot@gitlab.com>2023-08-30 21:22:07 +0300
committerGitLab Renovate Bot <gitlab-bot@gitlab.com>2023-08-30 21:22:07 +0300
commit4abdae28267a80552b1aa4ec7fd0fd2de35bc83b (patch)
tree059675eaa248bbe86ba7c545c6c51518c33cb71d /NOTICE
parentdb234c87ebaff374e91734527bcf9ce2bff357d5 (diff)
go: Update module github.com/hashicorp/golang-lru/v2 to v2.0.6
Diffstat (limited to 'NOTICE')
-rw-r--r--NOTICE249
1 files changed, 245 insertions, 4 deletions
diff --git a/NOTICE b/NOTICE
index 67b39a80a..63a420e5d 100644
--- a/NOTICE
+++ b/NOTICE
@@ -12660,6 +12660,9 @@ package lru
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
expirable_lru.go - github.com/hashicorp/golang-lru/v2/expirable
+// Copyright (c) HashiCorp, Inc.
+// SPDX-License-Identifier: MPL-2.0
+
package expirable
import (
@@ -12998,6 +13001,9 @@ func (c *LRU[K, V]) removeFromBucket(e *internal.Entry[K, V]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
expirable_lru_test.go - github.com/hashicorp/golang-lru/v2/expirable
+// Copyright (c) HashiCorp, Inc.
+// SPDX-License-Identifier: MPL-2.0
+
package expirable
import (
@@ -13515,6 +13521,50 @@ func getRand(tb testing.TB) int64 {
return out.Int64()
}
+func (c *LRU[K, V]) wantKeys(t *testing.T, want []K) {
+ t.Helper()
+ got := c.Keys()
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("wrong keys got: %v, want: %v ", got, want)
+ }
+}
+
+func TestCache_EvictionSameKey(t *testing.T) {
+ var evictedKeys []int
+
+ cache := NewLRU[int, struct{}](
+ 2,
+ func(key int, _ struct{}) {
+ evictedKeys = append(evictedKeys, key)
+ },
+ 0)
+
+ if evicted := cache.Add(1, struct{}{}); evicted {
+ t.Error("First 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1})
+
+ if evicted := cache.Add(2, struct{}{}); evicted {
+ t.Error("2: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ if evicted := cache.Add(1, struct{}{}); evicted {
+ t.Error("Second 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{2, 1})
+
+ if evicted := cache.Add(3, struct{}{}); !evicted {
+ t.Error("3: did not get expected eviction")
+ }
+ cache.wantKeys(t, []int{1, 3})
+
+ want := []int{2}
+ if !reflect.DeepEqual(evictedKeys, want) {
+ t.Errorf("evictedKeys got: %v want: %v", evictedKeys, want)
+ }
+}
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
go.mod - github.com/hashicorp/golang-lru/v2
module github.com/hashicorp/golang-lru/v2
@@ -13927,6 +13977,7 @@ lru_test.go - github.com/hashicorp/golang-lru/v2
package lru
import (
+ "reflect"
"testing"
)
@@ -14217,6 +14268,153 @@ func TestLRUResize(t *testing.T) {
}
}
+func (c *Cache[K, V]) wantKeys(t *testing.T, want []K) {
+ t.Helper()
+ got := c.Keys()
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("wrong keys got: %v, want: %v ", got, want)
+ }
+}
+
+func TestCache_EvictionSameKey(t *testing.T) {
+ t.Run("Add", func(t *testing.T) {
+ var evictedKeys []int
+
+ cache, _ := NewWithEvict(
+ 2,
+ func(key int, _ struct{}) {
+ evictedKeys = append(evictedKeys, key)
+ })
+
+ if evicted := cache.Add(1, struct{}{}); evicted {
+ t.Error("First 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1})
+
+ if evicted := cache.Add(2, struct{}{}); evicted {
+ t.Error("2: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ if evicted := cache.Add(1, struct{}{}); evicted {
+ t.Error("Second 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{2, 1})
+
+ if evicted := cache.Add(3, struct{}{}); !evicted {
+ t.Error("3: did not get expected eviction")
+ }
+ cache.wantKeys(t, []int{1, 3})
+
+ want := []int{2}
+ if !reflect.DeepEqual(evictedKeys, want) {
+ t.Errorf("evictedKeys got: %v want: %v", evictedKeys, want)
+ }
+ })
+
+ t.Run("ContainsOrAdd", func(t *testing.T) {
+ var evictedKeys []int
+
+ cache, _ := NewWithEvict(
+ 2,
+ func(key int, _ struct{}) {
+ evictedKeys = append(evictedKeys, key)
+ })
+
+ contained, evicted := cache.ContainsOrAdd(1, struct{}{})
+ if contained {
+ t.Error("First 1: got unexpected contained")
+ }
+ if evicted {
+ t.Error("First 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1})
+
+ contained, evicted = cache.ContainsOrAdd(2, struct{}{})
+ if contained {
+ t.Error("2: got unexpected contained")
+ }
+ if evicted {
+ t.Error("2: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ contained, evicted = cache.ContainsOrAdd(1, struct{}{})
+ if !contained {
+ t.Error("Second 1: did not get expected contained")
+ }
+ if evicted {
+ t.Error("Second 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ contained, evicted = cache.ContainsOrAdd(3, struct{}{})
+ if contained {
+ t.Error("3: got unexpected contained")
+ }
+ if !evicted {
+ t.Error("3: did not get expected eviction")
+ }
+ cache.wantKeys(t, []int{2, 3})
+
+ want := []int{1}
+ if !reflect.DeepEqual(evictedKeys, want) {
+ t.Errorf("evictedKeys got: %v want: %v", evictedKeys, want)
+ }
+ })
+
+ t.Run("PeekOrAdd", func(t *testing.T) {
+ var evictedKeys []int
+
+ cache, _ := NewWithEvict(
+ 2,
+ func(key int, _ struct{}) {
+ evictedKeys = append(evictedKeys, key)
+ })
+
+ _, contained, evicted := cache.PeekOrAdd(1, struct{}{})
+ if contained {
+ t.Error("First 1: got unexpected contained")
+ }
+ if evicted {
+ t.Error("First 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1})
+
+ _, contained, evicted = cache.PeekOrAdd(2, struct{}{})
+ if contained {
+ t.Error("2: got unexpected contained")
+ }
+ if evicted {
+ t.Error("2: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ _, contained, evicted = cache.PeekOrAdd(1, struct{}{})
+ if !contained {
+ t.Error("Second 1: did not get expected contained")
+ }
+ if evicted {
+ t.Error("Second 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ _, contained, evicted = cache.PeekOrAdd(3, struct{}{})
+ if contained {
+ t.Error("3: got unexpected contained")
+ }
+ if !evicted {
+ t.Error("3: did not get expected eviction")
+ }
+ cache.wantKeys(t, []int{2, 3})
+
+ want := []int{1}
+ if !reflect.DeepEqual(evictedKeys, want) {
+ t.Errorf("evictedKeys got: %v want: %v", evictedKeys, want)
+ }
+ })
+}
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LICENSE_list - github.com/hashicorp/golang-lru/v2/simplelru
This license applies to simplelru/list.go
@@ -14304,9 +14502,6 @@ func (c *LRU[K, V]) Add(key K, value V) (evicted bool) {
// Check for existing item
if ent, ok := c.items[key]; ok {
c.evictList.MoveToFront(ent)
- if c.onEvict != nil {
- c.onEvict(key, ent.Value)
- }
ent.Value = value
return false
}
@@ -14488,7 +14683,10 @@ lru_test.go - github.com/hashicorp/golang-lru/v2/simplelru
package simplelru
-import "testing"
+import (
+ "reflect"
+ "testing"
+)
func TestLRU(t *testing.T) {
evictCounter := 0
@@ -14693,6 +14891,49 @@ func TestLRU_Resize(t *testing.T) {
}
}
+func (c *LRU[K, V]) wantKeys(t *testing.T, want []K) {
+ t.Helper()
+ got := c.Keys()
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("wrong keys got: %v, want: %v ", got, want)
+ }
+}
+
+func TestCache_EvictionSameKey(t *testing.T) {
+ var evictedKeys []int
+
+ cache, _ := NewLRU(
+ 2,
+ func(key int, _ struct{}) {
+ evictedKeys = append(evictedKeys, key)
+ })
+
+ if evicted := cache.Add(1, struct{}{}); evicted {
+ t.Error("First 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1})
+
+ if evicted := cache.Add(2, struct{}{}); evicted {
+ t.Error("2: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{1, 2})
+
+ if evicted := cache.Add(1, struct{}{}); evicted {
+ t.Error("Second 1: got unexpected eviction")
+ }
+ cache.wantKeys(t, []int{2, 1})
+
+ if evicted := cache.Add(3, struct{}{}); !evicted {
+ t.Error("3: did not get expected eviction")
+ }
+ cache.wantKeys(t, []int{1, 3})
+
+ want := []int{2}
+ if !reflect.DeepEqual(evictedKeys, want) {
+ t.Errorf("evictedKeys got: %v want: %v", evictedKeys, want)
+ }
+}
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
testing_test.go - github.com/hashicorp/golang-lru/v2
// Copyright (c) HashiCorp, Inc.