本文整理汇总了Golang中redis.AsyncClient.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang AsyncClient.Get方法的具体用法?Golang AsyncClient.Get怎么用?Golang AsyncClient.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.AsyncClient
的用法示例。
在下文中一共展示了AsyncClient.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doGet
func doGet(id string, signal chan int, client redis.AsyncClient, cnt int) {
key := "set-" + id
for i := 0; i < cnt; i++ {
client.Get(key)
}
signal <- 1
}
示例2: load
func load(r redis.AsyncClient, k string, w http.ResponseWriter) (obj interface{}) {
f, rerr := r.Get(k)
if rerr != nil {
panic(rerr)
}
val, rerr, timeout := f.TryGet(50000000000)
if rerr != nil {
panic(rerr)
}
if timeout {
loadtimeout++
log.Println("load timeout! count: ", loadtimeout)
fmt.Fprintf(w, "Save failed for %s", key)
return
}
zr, err := zlib.NewReader(bytes.NewReader(val))
if err != nil {
log.Fatal("Failed to create zlib reader with error: ", err)
}
defer zr.Close()
jd := json.NewDecoder(zr)
err = jd.Decode(&obj)
if err != nil {
log.Fatal("Failed to decode json with error: ", err)
}
return
}
示例3: load
func load(r redis.AsyncClient, k string, w http.ResponseWriter) (obj interface{}) {
f, rerr := r.Get(k)
if rerr != nil {
panic(rerr)
}
val, rerr, timeout := f.TryGet(50000000000)
if rerr != nil {
panic(rerr)
}
if timeout {
loadtimeout++
log.Println("load timeout! count: ", loadtimeout)
fmt.Fprintf(w, "Save failed for %s", key)
return
}
setPromise, srerr := r.Set(key, val)
if srerr != nil {
panic(rerr)
}
_, grerr, timeout := setPromise.TryGet(50000000000)
if grerr != nil {
panic(rerr)
}
if timeout {
savetimeout++
log.Println("save timeout! count: ", savetimeout)
fmt.Fprintf(w, "Save failed for %s", key)
}
return
}