Added Key() method to Item
This commit is contained in:
4
item.go
4
item.go
@@ -55,6 +55,10 @@ func (i *Item[T]) shouldPromote(getsPerPromote int32) bool {
|
|||||||
return i.promotions == getsPerPromote
|
return i.promotions == getsPerPromote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Item[T]) Key() string {
|
||||||
|
return i.key
|
||||||
|
}
|
||||||
|
|
||||||
func (i *Item[T]) Value() T {
|
func (i *Item[T]) Value() T {
|
||||||
return i.value
|
return i.value
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,11 @@ import (
|
|||||||
"github.com/karlseguin/ccache/v3/assert"
|
"github.com/karlseguin/ccache/v3/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Test_Item_Key(t *testing.T) {
|
||||||
|
item := &Item[int]{key: "foo"}
|
||||||
|
assert.Equal(t, item.Key(), "foo")
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Item_Promotability(t *testing.T) {
|
func Test_Item_Promotability(t *testing.T) {
|
||||||
item := &Item[int]{promotions: 4}
|
item := &Item[int]{promotions: 4}
|
||||||
assert.Equal(t, item.shouldPromote(5), true)
|
assert.Equal(t, item.shouldPromote(5), true)
|
||||||
|
Reference in New Issue
Block a user