mirror of
https://github.com/silenceper/wechat.git
synced 2026-11-16 05:12:03 +08:00
1.增加redis支持 2.memcached支持多类型缓存
This commit is contained in:
1 parent
013f4ed585
commit
00ab67f623
3 files changed
+153
-11
No files matched your search
Vendored
+32
@@ -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