Skip to content

Commit

Permalink
interface fixed - generic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
parMaster committed May 28, 2024
1 parent 6e9cc8c commit 1744ddf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type Cache[T any] struct {
}

// Cacher is an interface for cache
type Cacher interface {
Set(key string, value interface{}, ttl int64) error
Get(key string) (interface{}, error)
type Cacher[T any] interface {
Set(key string, value T, ttl time.Duration) error
Get(key string) (T, error)
Has(key string) (bool, error)
Del(key string) error
Cleanup()
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ type testItem struct {
}

func Test_SimpleTest_Mcache(t *testing.T) {
c := NewCache[string]()
var c Cacher[string] // linter:ignore S1021
c = NewCache[string]()

assert.NotNil(t, c)
assert.IsType(t, &Cache[string]{}, c)
assert.NotNil(t, c.data)

testItems := []testItem{
{"key0", "value0", time.Second * 0},
Expand Down

0 comments on commit 1744ddf

Please sign in to comment.