本文整理匯總了Golang中github.com/hoisie/redis.Client.Expire方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Expire方法的具體用法?Golang Client.Expire怎麽用?Golang Client.Expire使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hoisie/redis.Client
的用法示例。
在下文中一共展示了Client.Expire方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setToBeHandled
func setToBeHandled(input string) {
c := redis.Client{Addr: addr, Password: pass}
c.Auth(pass)
c.Set(input, "1")
c.Expire(input, EXPIRETIME)
}
示例2: GetTempTicket
func GetTempTicket(expire_seconds int, scene_id int, scene_str string) string {
url := `https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=` + GetAccessToken()
data := `{"expire_seconds": ` + strconv.Itoa(expire_seconds) +
`, "action_name": "QR_SCENE", ` +
`"action_info": {"scene": {"scene_id": ` + strconv.Itoa(scene_id) +
`,"scene_str":"` + scene_str + `"}}}`
if ticket := getTicket(url, data); len(ticket) < 1 {
return ""
} else {
var redcli redis.Client
redcli.Addr = beego.AppConfig.String("redis_addr")
redcli.Hset(ticket, "scene_id", []byte(strconv.Itoa(scene_id)))
redcli.Expire(ticket, 120)
return ticket
}
}
示例3: getGroupArticle
func getGroupArticle(client redis.Client, group string, page int) []map[string]string {
order := "score:"
key := order + group
if ok, err := client.Exists(key); err != nil {
log.Fatal("Exists エラーだよ", err.Error())
} else if !ok {
//if _, err := client.Zinterstore(key, "group:" + group, order); err != nil {
// log.Fatal("Zinterstore エラーだよ", err.Error())
//}
if _, err := client.Expire(key, 60); err != nil {
log.Fatal("Expire エラーだよ", err.Error())
}
}
return getArticle(client, page, key)
}
示例4: postArticle
func postArticle(client redis.Client, user, title, link string) string {
id, err := client.Incr("article:")
if err != nil {
log.Fatal("Incrエラーだよ", err.Error())
}
articleID := strconv.FormatInt(id, 20)
voted := "voted:" + articleID
if _, err := client.Sadd(voted, []byte(user)); err != nil {
log.Fatal("Saddエラーだよ", err.Error())
}
if _, err := client.Expire(voted, int64(ONE_WEEK_DAY*time.Second)); err != nil {
log.Fatal("Expireエラーだよ", err.Error())
}
now := time.Now()
article := "article:" + articleID
fmt.Println("articleID", articleID)
if err := client.Hmset(article, map[string]string{
"title": title,
"link": link,
"poster": user,
"time": now.String(),
"votes": "1",
}); err != nil {
log.Fatal("Hmsetエラーだよ", err.Error())
}
if _, err := client.Zadd("score:", []byte(article), float64(now.Unix()+VOTE_SCORE)); err != nil {
log.Fatal("Zaddエラーだよ", err.Error())
}
if _, err := client.Zadd("time:", []byte(article), float64(now.Unix())); err != nil {
log.Fatal("Zaddエラーだよ", err.Error())
}
return articleID
}