mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-08 14:42:26 +08:00
1.增加redis支持 2.memcached支持多类型缓存
This commit is contained in:
32
cache/redis_test.go
vendored
Normal file
32
cache/redis_test.go
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRedis(t *testing.T) {
|
||||
opts := &RedisOpts{
|
||||
Host: "127.0.0.1:6379",
|
||||
}
|
||||
redis := NewRedis(opts)
|
||||
var err error
|
||||
timeoutDuration := 1 * time.Second
|
||||
|
||||
if err = redis.Set("username", "silenceper", timeoutDuration); err != nil {
|
||||
t.Error("set Error", err)
|
||||
}
|
||||
|
||||
if !redis.IsExist("username") {
|
||||
t.Error("IsExist Error")
|
||||
}
|
||||
|
||||
name := redis.Get("username").(string)
|
||||
if name != "silenceper" {
|
||||
t.Error("get Error")
|
||||
}
|
||||
|
||||
if err = redis.Delete("username"); err != nil {
|
||||
t.Errorf("delete Error , err=%v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user