Skip to content

Commit 52b1277

Browse files
committed
fix: resolve lint issues - remove unused field and add string constant
1 parent 30712ca commit 52b1277

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

internal/eviction/lru.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import (
99

1010
// LRUStrategy implements the LRU (Least Recently Used) eviction strategy
1111
type LRUStrategy struct {
12-
cache *lru.Cache[string, *entry.Entry]
13-
capacity int
14-
mutex sync.RWMutex
15-
evictCallback func(key string, value *entry.Entry)
16-
evictedKey string
17-
evictedValue *entry.Entry
12+
cache *lru.Cache[string, *entry.Entry]
13+
capacity int
14+
mutex sync.RWMutex
15+
evictedKey string
16+
evictedValue *entry.Entry
1817
}
1918

2019
// NewLRUStrategy creates a new LRU eviction strategy

pkg/obcache/cache_extra_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"time"
77
)
88

9+
const testValue1 = "value1"
10+
911
func TestCacheKeys(t *testing.T) {
1012
cache, err := New(NewDefaultConfig())
1113
if err != nil {
@@ -19,7 +21,7 @@ func TestCacheKeys(t *testing.T) {
1921
}
2022

2123
// Add some entries
22-
_ = cache.Set("key1", "value1", time.Hour)
24+
_ = cache.Set("key1", testValue1, time.Hour)
2325
_ = cache.Set("key2", "value2", time.Hour)
2426
_ = cache.Set("key3", "value3", time.Hour)
2527

@@ -54,7 +56,7 @@ func TestCacheLen(t *testing.T) {
5456
}
5557

5658
// Add some entries
57-
_ = cache.Set("key1", "value1", time.Hour)
59+
_ = cache.Set("key1", testValue1, time.Hour)
5860
if cache.Len() != 1 {
5961
t.Fatalf("Expected length 1, got %d", cache.Len())
6062
}
@@ -83,7 +85,7 @@ func TestCacheHas(t *testing.T) {
8385
}
8486

8587
// Add an entry
86-
_ = cache.Set("key1", "value1", time.Hour)
88+
_ = cache.Set("key1", testValue1, time.Hour)
8789

8890
if !cache.Has("key1") {
8991
t.Fatal("Cache should have key1")
@@ -124,7 +126,7 @@ func TestCacheTTLMethod(t *testing.T) {
124126
if !found {
125127
t.Fatal("Should find existing key")
126128
}
127-
if value != "value1" {
129+
if value != testValue1 {
128130
t.Fatalf("Expected value1, got %v", value)
129131
}
130132

@@ -163,7 +165,7 @@ func TestCacheClear(t *testing.T) {
163165
}
164166

165167
// Add multiple entries
166-
_ = cache.Set("key1", "value1", time.Hour)
168+
_ = cache.Set("key1", testValue1, time.Hour)
167169
_ = cache.Set("key2", "value2", time.Hour)
168170
_ = cache.Set("key3", "value3", time.Hour)
169171

@@ -192,7 +194,7 @@ func TestCacheClose(t *testing.T) {
192194
}
193195

194196
// Add an entry
195-
_ = cache.Set("key1", "value1", time.Hour)
197+
_ = cache.Set("key1", testValue1, time.Hour)
196198

197199
// Close should not error
198200
_ = cache.Close() // Test cleanup
@@ -254,7 +256,7 @@ func TestCacheClearWithHooks(t *testing.T) {
254256
}
255257

256258
// Add multiple entries
257-
_ = cache.Set("key1", "value1", time.Hour)
259+
_ = cache.Set("key1", testValue1, time.Hour)
258260
_ = cache.Set("key2", "value2", time.Hour)
259261

260262
// Invalidate all should trigger hooks

0 commit comments

Comments
 (0)