예제 #1
0
func doIncr(id string, signal chan int, client redis.AsyncClient, cnt int) {
	key := "ctr-" + id
	for i := 0; i < cnt; i++ {
		client.Incr(key)
	}
	signal <- 1
}
예제 #2
0
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
}