rds_cache_go/cache_test.go
2021-12-06 16:03:12 +08:00

39 lines
658 B
Go

package rds_cache_go
import (
"fmt"
"testing"
"time"
)
var caches = NewCache(WithHost("192.168.0.151"), WithPort("6379"), WithDbname(13))
func TestCache(t *testing.T) {
err := caches.Put("key1", "va", 1*time.Minute)
if err != nil {
fmt.Printf("存放失败")
}
fmt.Println("放入存放成功")
}
func TestCache_Exist(t *testing.T) {
exi := caches.Exist("key1")
fmt.Println(exi)
}
func TestCache_Get(t *testing.T) {
result := caches.Get("key1")
fmt.Println(result)
}
func TestCache_Delete(t *testing.T) {
caches.Put("key1", "value1", 0)
caches.Put("key2", "value2", 0)
resunt := caches.Delete("key1", "key2")
fmt.Println(resunt)
}