@@ -21,23 +21,23 @@ type ARCCache[K comparable, V any] struct {
21
21
size int // Size is the total capacity of the cache
22
22
p int // P is the dynamic preference towards T1 or T2
23
23
24
- t1 simplelru.LRUCache [K , V ] // T1 is the LRU for recently accessed items
25
- b1 simplelru.LRUCache [K , V ] // B1 is the LRU for evictions from t1
24
+ t1 simplelru.LRUCache [K , V ] // T1 is the LRU for recently accessed items
25
+ b1 simplelru.LRUCache [K , struct {} ] // B1 is the LRU for evictions from t1
26
26
27
- t2 simplelru.LRUCache [K , V ] // T2 is the LRU for frequently accessed items
28
- b2 simplelru.LRUCache [K , V ] // B2 is the LRU for evictions from t2
27
+ t2 simplelru.LRUCache [K , V ] // T2 is the LRU for frequently accessed items
28
+ b2 simplelru.LRUCache [K , struct {} ] // B2 is the LRU for evictions from t2
29
29
30
30
lock sync.RWMutex
31
31
}
32
32
33
33
// NewARC creates an ARC of the given size
34
34
func NewARC [K comparable , V any ](size int ) (* ARCCache [K , V ], error ) {
35
35
// Create the sub LRUs
36
- b1 , err := simplelru .NewLRU [K , V ](size , nil )
36
+ b1 , err := simplelru .NewLRU [K , struct {} ](size , nil )
37
37
if err != nil {
38
38
return nil , err
39
39
}
40
- b2 , err := simplelru .NewLRU [K , V ](size , nil )
40
+ b2 , err := simplelru .NewLRU [K , struct {} ](size , nil )
41
41
if err != nil {
42
42
return nil , err
43
43
}
@@ -185,14 +185,12 @@ func (c *ARCCache[K, V]) replace(b2ContainsKey bool) {
185
185
if t1Len > 0 && (t1Len > c .p || (t1Len == c .p && b2ContainsKey )) {
186
186
k , _ , ok := c .t1 .RemoveOldest ()
187
187
if ok {
188
- var empty V
189
- c .b1 .Add (k , empty )
188
+ c .b1 .Add (k , struct {}{})
190
189
}
191
190
} else {
192
191
k , _ , ok := c .t2 .RemoveOldest ()
193
192
if ok {
194
- var empty V
195
- c .b2 .Add (k , empty )
193
+ c .b2 .Add (k , struct {}{})
196
194
}
197
195
}
198
196
}
0 commit comments