diff --git a/cache.go b/cache.go index 1b9e72e..fbfaebe 100644 --- a/cache.go +++ b/cache.go @@ -153,7 +153,7 @@ func (c *Cache[K, V]) set(key K, value V, ttl time.Duration) *Item[K, V] { } // create a new item - item := newItem(key, value, ttl, c.options.enableVersionTracking) + item := NewItem(key, value, ttl, c.options.enableVersionTracking) elem = c.items.lru.PushFront(item) c.items.values[key] = elem c.updateExpirations(true, elem) diff --git a/cache_test.go b/cache_test.go index f88b2e0..68bd340 100644 --- a/cache_test.go +++ b/cache_test.go @@ -1245,7 +1245,7 @@ func prepCache(ttl time.Duration, keys ...string) *Cache[string, string] { func addToCache(c *Cache[string, string], ttl time.Duration, keys ...string) { for i, key := range keys { - item := newItem( + item := NewItem( key, fmt.Sprint("value of", key), ttl+time.Duration(i)*time.Minute, diff --git a/item.go b/item.go index c3c26cf..92eb73b 100644 --- a/item.go +++ b/item.go @@ -39,8 +39,8 @@ type Item[K comparable, V any] struct { version int64 } -// newItem creates a new cache item. -func newItem[K comparable, V any](key K, value V, ttl time.Duration, enableVersionTracking bool) *Item[K, V] { +// NewItem creates a new cache item. +func NewItem[K comparable, V any](key K, value V, ttl time.Duration, enableVersionTracking bool) *Item[K, V] { item := &Item[K, V]{ key: key, value: value, diff --git a/item_test.go b/item_test.go index 0d001a7..7e7699e 100644 --- a/item_test.go +++ b/item_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" ) -func Test_newItem(t *testing.T) { - item := newItem("key", 123, time.Hour, false) +func Test_NewItem(t *testing.T) { + item := NewItem("key", 123, time.Hour, false) require.NotNil(t, item) assert.Equal(t, "key", item.key) assert.Equal(t, 123, item.value)