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-03-17 16:14:25 +08:00
|
|
|
cachex.NewCache("").Set("test", "test", time.Second*5)
|
2023-11-24 22:28:22 +08:00
|
|
|
|
2024-03-17 16:14:25 +08:00
|
|
|
da, err := cachex.NewCache("").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-03-17 16:14:25 +08:00
|
|
|
da, err = cachex.NewCache("").Get("test")
|
2023-12-29 16:27:47 +08:00
|
|
|
fmt.Println(da, err)
|
2023-11-24 22:28:22 +08:00
|
|
|
}
|