本文整理匯總了Golang中github.com/monnand/goredis.Client.Db方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Db方法的具體用法?Golang Client.Db怎麽用?Golang Client.Db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/monnand/goredis.Client
的用法示例。
在下文中一共展示了Client.Db方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newPushRedisDB
func newPushRedisDB(c *DatabaseConfig) (*PushRedisDB, error) {
if c == nil {
return nil, errors.New("Invalid Database Config")
}
if strings.ToLower(c.Engine) != "redis" {
return nil, errors.New("Unsupported Database Engine")
}
var client redis.Client
if c.Host == "" {
c.Host = "localhost"
}
if c.Port <= 0 {
c.Port = 6379
}
if c.Name == "" {
c.Name = "0"
}
client.Addr = fmt.Sprintf("%s:%d", c.Host, c.Port)
client.Password = c.Password
var err error
client.Db, err = strconv.Atoi(c.Name)
if err != nil {
client.Db = 0
}
ret := new(PushRedisDB)
ret.client = &client
ret.psm = c.PushServiceManager
if ret.psm == nil {
ret.psm = GetPushServiceManager()
}
return ret, nil
}
示例2: clearData
func clearData() {
var client redis.Client
c := dbconf
if c.Host == "" {
c.Host = "localhost"
}
if c.Port <= 0 {
c.Port = 6379
}
if c.Name == "" {
c.Name = "0"
}
client.Addr = fmt.Sprintf("%s:%d", c.Host, c.Port)
client.Password = c.Password
var err error
client.Db, err = strconv.Atoi(c.Name)
if err != nil {
client.Db = 0
}
client.Flush(true)
}