// // memory_test.go // Copyright (C) 2023 tiglog // // Distributed under terms of the MIT license. // package gcache_test import ( "testing" "time" "git.hexq.cn/tiglog/golib/gcache" "git.hexq.cn/tiglog/golib/gtest" ) func TestUsage(t *testing.T) { c := gcache.NewMemCache() c.Set("a", 1) c.Set("b", 1, gcache.WithEx(1*time.Second)) time.Sleep(1 * time.Second) r1, ok := c.Get("a") // 1, true gtest.True(t, ok) gtest.Equal(t, 1, r1) r2, ok := c.Get("b") gtest.False(t, ok) gtest.Nil(t, r2) }