本文整理匯總了Golang中github.com/hoisie/redis.Client.Rpush方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Rpush方法的具體用法?Golang Client.Rpush怎麽用?Golang Client.Rpush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hoisie/redis.Client
的用法示例。
在下文中一共展示了Client.Rpush方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetUserList
/// 獲取用戶列表並報錯到redis數據庫中 KEY=wx_UserList
func GetUserList() {
url := "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + GetAccessToken()
key := "wx_UserList"
var v WXUserList
c, status := global.HttpGet(url)
if status >= 0 {
dec := json.NewDecoder(strings.NewReader(c))
for {
if err := dec.Decode(&v); err == io.EOF {
break
} else if err != nil {
log.Fatal(err)
}
}
var redcli redis.Client
redcli.Addr = beego.AppConfig.String("redis_addr")
if ok, err := redcli.Exists(key); err != nil {
log.Println(err.Error())
} else {
if ok {
redcli.Del(key)
}
}
for _, value := range v.Data.Openid {
redcli.Rpush(key, []byte(value))
}
log.Println("Successful: Add Userlist ")
}
}
示例2: main
func main() {
// Create client and tell it about our job
client := gtw.New(4, "go-to-work")
client.AddJobHandler("SayHello", SayHelloJob{})
client.BeginPolling()
// Push sample messages
wait.Add(5)
var redisClient redis.Client
redisClient.Rpush("go-to-work", []byte(`{"Name": "SayHello", "Params": {"Greeting": "Susan"}}`))
redisClient.Rpush("go-to-work", []byte(`{"Name": "SayHello", "Params": {"Greeting": "Jim"}}`))
time.Sleep(1 * time.Second)
redisClient.Rpush("go-to-work", []byte(`{"Name": "SayHello", "Params": {"Greeting": "Stefanie"}}`))
redisClient.Rpush("go-to-work", []byte(`{"Name": "SayHello", "Params": {"Greeting": "Brian"}}`))
redisClient.Rpush("go-to-work", []byte(`{"Name": "SayHello", "Params": {"Greeting": "Dan"}}`))
wait.Wait()
}