mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 17:41:57 +08:00
Feat: ttl in memory-cache / Add: webdav from standard library
This commit is contained in:
12
pkg/cache/memo_test.go
vendored
12
pkg/cache/memo_test.go
vendored
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user