7 Star 26 Fork 2

Gitee 极速下载 / goworld

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/xiaonanln/goworld
克隆/下载
gwredis.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
seis 提交于 2017-10-18 10:28 . gw - redis
package gwredis
import (
"github.com/garyburd/redigo/redis"
"github.com/xiaonanln/goworld/engine/async"
)
const (
_REDIS_ASYNC_JOB_GROUP = "_redis"
)
type DB struct {
conn redis.Conn
}
func Dial(network, address string, options []redis.DialOption, ac async.AsyncCallback) {
async.AppendAsyncJob(_REDIS_ASYNC_JOB_GROUP, func() (res interface{}, err error) {
conn, err := redis.Dial(network, address, options...)
if err == nil {
return &DB{conn}, nil
} else {
return nil, err
}
}, ac)
}
func DialURL(rawurl string, options []redis.DialOption, ac async.AsyncCallback) {
async.AppendAsyncJob(_REDIS_ASYNC_JOB_GROUP, func() (res interface{}, err error) {
conn, err := redis.DialURL(rawurl, options...)
if err == nil {
return &DB{conn}, nil
} else {
return nil, err
}
}, ac)
}
func (db *DB) Do(commandName string, args []interface{}, ac async.AsyncCallback) {
async.AppendAsyncJob(_REDIS_ASYNC_JOB_GROUP, func() (res interface{}, err error) {
res, err = db.conn.Do(commandName, args...)
return
}, ac)
}
1
https://gitee.com/mirrors/goworld.git
git@gitee.com:mirrors/goworld.git
mirrors
goworld
goworld
v0.1.6

搜索帮助