1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2023-08-25 15:31:00 +08:00
parent 04aecd4abc
commit b0a97978d8
58 changed files with 1330 additions and 476 deletions

View File

@ -3,27 +3,38 @@ package cache
import (
"testing"
"time"
"github.com/charlienet/go-mixed/logx"
)
func TestBuilder(t *testing.T) {
cache, err := NewCacheBuilder().
WithLogger(logx.NewLogrus(logx.WithFormatter(logx.NewNestedFormatter(logx.NestedFormatterOption{
Color: true,
})))).
WithRedis(RedisConfig{
Addrs: []string{"192.168.2.222:6379"},
Password: "123456",
}).
WithBigCache(BigCacheConfig{}).
// WithFreeCache(10 * 1024 * 1024).
Build()
now := time.Now()
t.Log(now)
t1, _ := time.ParseDuration("9h27m")
t1 += time.Hour * 24
t2, _ := time.ParseDuration("16h28m")
t.Log(t1)
t.Log(t2)
if err != nil {
t.Fatal(err)
}
f := time.Date(2022, time.December, 12, 8, 0, 0, 0, time.Local)
t.Log(f.Sub(time.Now()))
u := SimpleUser{FirstName: "Radomir", LastName: "Sohlich"}
t.Log(cache.Set(defaultKey, u, time.Minute*10))
// cache, err := New(
// WithLogger(logx.NewLogrus(logx.WithNestedFormatter(logx.NestedFormatterOption{
// Color: true,
// }))).
// UseRedis(RedisConfig{
// Addrs: []string{"192.168.2.222:6379"},
// Password: "123456",
// }).
// UseBigCache(bigcache.BigCacheConfig{}).
// Build()
// if err != nil {
// t.Fatal(err)
// }
// ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
// defer cancel()
// u := SimpleUser{FirstName: "Radomir", LastName: "Sohlich"}
// t.Log(cache.Set(ctx, defaultKey, u, time.Minute*10))
}