Exemple #1
0
func InitMysql() {

	dbhost := config.GetConfig("mysql_host")
	dbuser := config.GetConfig("mysql_user")
	dbpass := config.GetConfig("mysql_pass")
	dbname := config.GetConfig("mysql_dbname")

	orm.RegisterDriver("mysql", orm.DRMySQL)
	//username:password@protocol(address)/dbname?param=value
	conn := dbuser + ":" + dbpass + "@tcp(" + dbhost + ")/" + dbname + "?charset=utf8"
	//fmt.Printf("ConnString %v\n",conn)
	orm.RegisterDataBase("default", "mysql", conn)

}
Exemple #2
0
func (this *Redis) Init() {
	this.pool = redis.NewPool(func() (redis.Conn, error) {
		return redis.Dial("tcp", config.GetConfig("redis_host"))
	}, 20)
	this.pool.IdleTimeout = 45 * time.Second
	this.pool.MaxActive = 30
	this.pool.MaxIdle = 30
}