You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
400 B

package kvcache
import (
"fmt"
"testing"
"time"
"github.com/fanjindong/go-cache"
)
func TestCache(t *testing.T) {
c := cache.NewMemCache(cache.WithShards(8), cache.WithClearInterval(time.Minute))
c.Set("a", 1)
c.Set("b", 1, cache.WithEx(1*time.Second))
time.Sleep(1 * time.Second)
v, ok := c.Get("a") // 1, true
fmt.Println(v, ok)
v, ok = c.Get("b") // nil, false
fmt.Println(v, ok)
}