fix bug and test set expireTime
This commit is contained in:
parent
42484e3f96
commit
d1fb560578
|
@ -53,3 +53,19 @@ func TestFlushMapVal(t *testing.T) {
|
||||||
fmt.Println(vv.Get(ctx, 6))
|
fmt.Println(vv.Get(ctx, 6))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetExpireTime(t *testing.T) {
|
||||||
|
t.Run("t1", func(t *testing.T) {
|
||||||
|
c := NewMemoryMapCache[string, string](nil, nil, time.Second, "xx")
|
||||||
|
c.Set(ctx, "xx", "yy")
|
||||||
|
fmt.Println(c.Get(ctx, "xx"))
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
fmt.Println(c.Get(ctx, "xx"))
|
||||||
|
SetExpireTime(3*time.Second, "xx")
|
||||||
|
c.Set(ctx, "xx", "yyy")
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
fmt.Println(c.Get(ctx, "xx"))
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
fmt.Println(c.Get(ctx, "xx"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ func Push(fn func(), a ...any) {
|
||||||
|
|
||||||
func Reload() {
|
func Reload() {
|
||||||
anyMap.Flush()
|
anyMap.Flush()
|
||||||
safetyMaps.Flush()
|
//safetyMaps.Flush()
|
||||||
callsM.Flush()
|
callsM.Flush()
|
||||||
flushMapFn.Flush()
|
flushMapFn.Flush()
|
||||||
callll := calls.Load()
|
callll := calls.Load()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user