代码拉取完成,页面将自动刷新
package redis
import (
redigo "gopkg.in/redis.v3"
"time"
)
var client = redigo.NewClient(&redigo.Options{
Addr: "192.168.1.252:6379",
Password: "", // no password set
DB: 0, // use default DB
})
// Cache is a Redis Image Cache.
// https://gopkg.in/redis.v3
type Cache struct {
Expire time.Duration // optional
}
func NewCache(expire int64) *Cache {
return &Cache{time.Duration(expire) * time.Second}
}
/**
* redis Get
*/
func (cache *Cache) Get(key string) (string, error) {
value, err := client.Get(key).Result()
return value, err
}
/**
* redis Set
*/
func (cache *Cache) Set(key, value string) error {
err := client.Set(key, value, cache.Expire).Err()
return err
}
func (cache *Cache) SetByte(key string, value []byte) error {
return cache.Set(key, string(value))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。