2023-11-24 22:28:22 +08:00
|
|
|
package cachex_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"code.yun.ink/pkg/cachex"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCache(t *testing.T) {
|
2024-04-12 16:44:21 +08:00
|
|
|
c := cachex.NewCache()
|
2023-11-24 22:28:22 +08:00
|
|
|
|
2024-04-12 16:33:00 +08:00
|
|
|
c.Set("test", "test", time.Second*5)
|
|
|
|
|
|
|
|
|
|
da, err := c.Get("test")
|
2023-12-29 16:27:47 +08:00
|
|
|
fmt.Println(da, err)
|
2023-11-24 22:28:22 +08:00
|
|
|
|
2023-12-29 16:27:47 +08:00
|
|
|
time.Sleep(time.Second * 5)
|
2024-04-12 16:33:00 +08:00
|
|
|
da, err = c.Get("test")
|
2023-12-29 16:27:47 +08:00
|
|
|
fmt.Println(da, err)
|
2023-11-24 22:28:22 +08:00
|
|
|
}
|