# README
redis
初始化
只支持单例 redis
import "github.com/go-eyas/toolkit/redis"
func main() {
// 使用前必须先初始化
r, err := redis.Init(&redis.Config{
Cluster: false, // 是否集群
Addrs: []string{"10.0.3.252:6379"}, // redis 地址,如果是集群则在数组上写多个元素
Password: "",
DB: 1,
})
if err != nil {
panic(err)
}
err = r.Set("tookit:test", `{"hello": "world"}`)
v, err = r.Get("tookit:test")
fmt.Printf("v: %s", v) // v: {"hello": "world"}
err = redis.Del("tookit:test")
redis.Expire("tookit:test", time.Hour * 24)
redis.Redis // *redis.RedisClient
redis.Client // *github.com/go-redis/redis.Client
}
godoc
# Functions
Init 初始化redis.
# Variables
RedisTTL 默认有效期 24 小时.
# Structs
No description provided by the author
No description provided by the author
RedisClient redis client wrapper.