Feat: ttl in memory-cache / Add: webdav from standard library

This commit is contained in:
HFO4
2019-12-16 18:56:25 +08:00
parent e6d2a94809
commit 327a3c1edf
15 changed files with 7372 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package cache
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestNewMemoStore(t *testing.T) {
@ -22,7 +23,7 @@ func TestMemoStore_Set(t *testing.T) {
val, ok := store.Store.Load("KEY")
asserts.True(ok)
asserts.Equal("vAL", val)
asserts.Equal("vAL", val.(itemWithTTL).value)
}
func TestMemoStore_Get(t *testing.T) {
@ -58,6 +59,15 @@ func TestMemoStore_Get(t *testing.T) {
asserts.Equal(test, res)
}
// 过期
{
_ = store.Set("string", "string_val", 1)
time.Sleep(time.Duration(2) * time.Second)
val, ok := store.Get("string")
asserts.Nil(val)
asserts.False(ok)
}
}
func TestMemoStore_Gets(t *testing.T) {