9 Star 44 Fork 6

kelvins-io / g2cache

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
redis_helper_test.go 888 Bytes
Copy Edit Web IDE Raw Blame History
cristiane authored 2021-06-25 01:22 . !3 发布订阅fix
package g2cache
import (
"github.com/gomodule/redigo/redis"
"testing"
)
func TestGetRedisPool(t *testing.T) {
DefaultRedisConf.DSN = "127.0.0.1:6379"
DefaultRedisConf.DB = 0
DefaultRedisConf.Pwd = ""
DefaultRedisConf.MaxConn = 3
pool, err := GetRedisPool(&DefaultRedisConf)
if err != nil {
t.Fatal(err)
return
}
DefaultPubSubRedisConf = DefaultRedisConf
pubsubPool, err := GetRedisPool(&DefaultPubSubRedisConf)
if err != nil {
t.Fatal(err)
return
}
_, err = pool.Get().Do("SET", "surprise", "g2cache")
if err != nil {
t.Fatal(err)
return
}
v, err := redis.String(pool.Get().Do("GET", "surprise"))
if err != nil {
t.Fatal(err)
return
}
t.Log("GET surprise=", v)
err = RedisPublish(DefaultPubSubRedisChannel, "set surprise g2cache", pubsubPool)
if err != nil {
t.Fatal(err)
return
}
t.Logf("channel %s publish ok", DefaultPubSubRedisChannel)
}

Comment ( 0 )

Sign in for post a comment

Go
1
https://gitee.com/kelvins-io/g2cache.git
git@gitee.com:kelvins-io/g2cache.git
kelvins-io
g2cache
g2cache
release

Search