1 Star 0 Fork 0

wuzpdev/goworld

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gwredis.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
seis 提交于 2017-10-18 10:28 +08:00 . 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)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzpdev/goworld.git
git@gitee.com:wuzpdev/goworld.git
wuzpdev
goworld
goworld
v0.1.6

搜索帮助