1 Star 0 Fork 0

Injection / goStart

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
database.go 632 Bytes
一键复制 编辑 原始数据 按行查看 历史
yinh 提交于 2015-03-29 22:33 . update readme_zh link to relate
package main
import (
"fmt"
"github.com/fzzy/radix/redis"
"github.com/golang/glog"
"github.com/golang/groupcache"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
// all database connection
type Database struct {
Mgo *mgo.Session "mongodb"
Client *redis.Client "redis"
Cache *groupcache.Group
}
// init data connection
func (d *Database) Init() error {
sess, err := mgo.Dial("localhost")
if err != nil {
glog.Error(err)
return err
}
d.Mgo = sess
client, err := redis.Dial("tcp", "localhost:6379")
if err != nil {
glog.Error(err)
sess.Close()
return err
}
d.Client = client
return nil
}
Go
1
https://gitee.com/tfzxyinhao/goStart.git
git@gitee.com:tfzxyinhao/goStart.git
tfzxyinhao
goStart
goStart
master

搜索帮助