56 Star 153 Fork 40

青苗 / gmfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
redis.go 802 Bytes
一键复制 编辑 原始数据 按行查看 历史
= 提交于 2015-08-13 11:29 . golang 基于 gridFs 的分布式文件服务
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))
}
Go
1
https://gitee.com/jobob/gmfs.git
git@gitee.com:jobob/gmfs.git
jobob
gmfs
gmfs
8375e82f13e4

搜索帮助