2021-05-07 09:05:20 +08:00
|
|
|
package rds_cache_go
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2021-12-06 16:09:12 +08:00
|
|
|
var caches = NewCache(WithHost("192.168.0.151"), WithPort("6379"), WithDB(13))
|
2021-05-07 09:05:20 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|