当前位置: 首页>>代码示例>>Golang>>正文


Golang redis.AsyncClient类代码示例

本文整理汇总了Golang中redis.AsyncClient的典型用法代码示例。如果您正苦于以下问题:Golang AsyncClient类的具体用法?Golang AsyncClient怎么用?Golang AsyncClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AsyncClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: asyncFlushAndQuitOnCompletion

func asyncFlushAndQuitOnCompletion(t *testing.T, client redis.AsyncClient) {
	// flush it
	fStat, e := client.Flushdb()
	if e != nil {
		t.Errorf("on Flushdb - %s", e)
	}
	ok, fe := fStat.Get()
	if fe != nil {
		t.Fatalf("BUG - non-Error future result get must never return error - got: %s", fe)
	}
	if !ok {
		t.Fatalf("BUG - non-Error flushdb future result must always be true ")
	}

	fStat, e = client.Quit()
	if e != nil {
		t.Errorf("on Quit - %s", e)
	}
	ok, fe = fStat.Get()
	if fe != nil {
		t.Fatalf("BUG - non-Error future result get must never return error - got: %s", fe)
	}
	if !ok {
		t.Fatalf("BUG - non-Error quit future result must always be true ")
	}
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:26,代码来源:async_test.go

示例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
}
开发者ID:rmoorman,项目名称:web-bench,代码行数:27,代码来源:app.go

示例3: save

func save(r redis.AsyncClient, key string, obj interface{}, w http.ResponseWriter) {
	var b bytes.Buffer

	z := zlib.NewWriter(&b)
	defer z.Close()

	je := json.NewEncoder(z)

	err := je.Encode(obj)
	if err != nil {
		log.Fatal("Failed to json Encode with error: ", err)
	}
	z.Flush()

	f, rerr := r.Set(key, b.Bytes())
	if rerr != nil {
		panic(rerr)
	}
	_, rerr, timeout := f.TryGet(50000000000)
	if rerr != nil {
		panic(rerr)
	}
	if timeout {
		savetimeout++
		log.Println("save timeout! count: ", savetimeout)
		fmt.Fprintf(w, "Save failed for %s", key)
	}
}
开发者ID:rmoorman,项目名称:web-bench,代码行数:28,代码来源:app.go

示例4: doRpop

func doRpop(id string, signal chan int, client redis.AsyncClient, cnt int) {
	key := "list-R" + id
	for i := 0; i < cnt; i++ {
		client.Rpop(key)
	}
	signal <- 1
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:7,代码来源:asyncbench.go

示例5: primeKey

func primeKey(key string, r redis.AsyncClient) {
	path := "document.json"
	file, err := os.Open(path)
	if err != nil {
		panic(err)
	}
	reader := bufio.NewReader(file)
	document, _ := ioutil.ReadAll(reader)
	var b bytes.Buffer
	z := zlib.NewWriter(&b)
	z.Write(document)
	z.Close()
	f, rerr := r.Set(key, b.Bytes())
	if rerr != nil {
		panic(rerr)
	}
	_, rerr, timeout := f.TryGet(50000000000)
	if rerr != nil {
		panic(rerr)
	}
	if timeout {
		savetimeout++
		log.Println("save timeout! count: ", savetimeout)
	}
}
开发者ID:rmoorman,项目名称:web-bench,代码行数:25,代码来源:app.go

示例6: 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
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:7,代码来源:asyncbench.go

示例7: doDecr

func doDecr(id string, signal chan int, client redis.AsyncClient, cnt int) {
	key := "ctr-" + id
	for i := 0; i < cnt; i++ {
		client.Decr(key)
	}
	signal <- 1
}
开发者ID:chronicaww,项目名称:Go-Redis,代码行数:7,代码来源:asyncbench.go

示例8: 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
}
开发者ID:rmoorman,项目名称:web-bench,代码行数:30,代码来源:app-no-json.go

示例9: doRpush

func doRpush(id string, signal chan int, client redis.AsyncClient, cnt int) {
	key := "list-R-" + id
	value := []byte("foo")
	for i := 0; i < cnt; i++ {
		client.Rpush(key, value)
	}
	signal <- 1
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:8,代码来源:asyncbench.go

示例10: doSet

func doSet(id string, signal chan int, client redis.AsyncClient, cnt int) {
	key := "set-" + id
	value := []byte("foo")
	for i := 0; i < cnt; i++ {
		client.Set(key, value)
	}
	signal <- 1
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:8,代码来源:asyncbench.go

示例11: doPing

func doPing(id string, signal chan int, client redis.AsyncClient, cnt int) {
	var fr redis.FutureBool
	for i := 0; i < cnt; i++ {
		fr, _ = client.Ping()
	}
	fr.Get()
	signal <- 1
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:8,代码来源:asyncbench.go

示例12: doDecr

func doDecr(id string, signal chan int, client redis.AsyncClient, cnt int) {
	var fr redis.FutureInt64
	key := "ctr-" + id
	for i := 0; i < cnt; i++ {
		fr, _ = client.Decr(key)
	}
	fr.Get()
	signal <- 1
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:9,代码来源:asyncbench.go

示例13: setup

func setup(client redis.AsyncClient) {
	fr, e := client.Flushdb()
	if e != nil {
		log.Println("Error creating client for worker: ", e)
		log.Println("fr: ", fr)
		panic(e)
	}
	frr, e2 := fr.Get()
	if e2 != nil {
		log.Println("Error creating client for worker: ", e2)
		log.Println("frr: ", frr)
		panic(e)
	}
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:14,代码来源:asyncbench.go

示例14: QuitAsyncClient

func QuitAsyncClient(t *testing.T, client redis.AsyncClient) {
	// flush it
	fstat, e := client.Quit()
	if e != nil {
		t.Fatalf("on Quit - %s", e)
	}
	ok, fe := fstat.Get()
	if fe != nil {
		t.Fatalf("on fstat.Get() - %s", fe)
	}
	if !ok {
		t.Fatalf("fstat.Get() returned false")
	}
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:14,代码来源:support.go

示例15: doIncr

func doIncr(id string, signal chan int, client redis.AsyncClient, cnt int) {
	key := "ctr-" + id
	var fr redis.FutureInt64
	for i := 0; i < cnt; i++ {
		fr, _ = client.Incr(key)
	}
	v, _ := fr.Get()
	if v != int64(cnt) {
		log.Fatalf("BUG: expecting counter %s to be %d but it is %d\n", key, cnt, v)
		panic(1)
	}
	// debug sanity check
	//	log.Printf("worker[%s] - last INCR result %s=%d\n", id, key, v)
	signal <- 1
}
开发者ID:aaudis,项目名称:GoRedisSession,代码行数:15,代码来源:asyncbench.go


注:本文中的redis.AsyncClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。