Esempio n. 1
0
// NewBoltHelper function description : 新建Bolt
// params :
// return :
func NewBoltHelper(dbname string, mode int, logger *Log4FE) *BoltHelper {
	var err error
	this := &BoltHelper{name: dbname, Logger: logger}
	this.db, err = bolt.Open(dbname, 0666, nil)
	if err != nil {
		this.Logger.Error("[ERROR] Open Dbname Error %v", err)
	}

	return this

}
Esempio n. 2
0
// GetBoltInstance function description : 获取单例引用
// params :
// return :
func GetBoltInstance() *BoltHelper {

	if gBoltHelper == nil {
		var err error
		this := &BoltHelper{name: "default.db", Logger: nil}
		this.db, err = bolt.Open(this.name, 0666, nil)
		if err != nil {
			this.Logger.Error("[ERROR] Open Dbname Error %v", err)
		}
		gBoltHelper = this
	}
	return gBoltHelper
}
Esempio n. 3
0
// NewBoltInstance function description : 新建单体引用
// params :
// return :
func NewBoltInstance(dbname string, mode int, logger *Log4FE) *BoltHelper {

	if gBoltHelper != nil {
		return gBoltHelper
	}
	var err error
	gBoltHelper = &BoltHelper{name: dbname, Logger: logger}
	gBoltHelper.db, err = bolt.Open(dbname, 0666, nil)
	if err != nil {
		gBoltHelper.Logger.Error("[ERROR] Open Dbname Error %v", err)
	}

	return gBoltHelper

}