示例#1
0
func FlushClient(t *testing.T, client redis.Client) {
	// flush it
	e := client.Flushdb()
	if e != nil {
		t.Fatalf("on Flushdb - %s", e)
	}
}
示例#2
0
func doPing(client redis.Client, cnt int) (delta int64) {
	t0 := time.Nanoseconds()
	for i := 0; i < cnt; i++ {
		client.Ping()
	}
	delta = time.Nanoseconds() - t0
	client.Flushdb()
	return
}
示例#3
0
func doPing(client redis.Client, cnt int) (delta time.Duration) {
	t0 := time.Now()
	for i := 0; i < cnt; i++ {
		client.Ping()
	}
	delta = time.Now().Sub(t0)
	client.Flushdb()
	return
}
示例#4
0
func doIncr(client redis.Client, cnt int) (delta int64) {
	key := "ctr"
	t0 := time.Nanoseconds()
	for i := 0; i < cnt; i++ {
		client.Incr(key)
	}
	delta = time.Nanoseconds() - t0
	client.Flushdb()
	return
}
示例#5
0
func doGet(client redis.Client, cnt int) (delta time.Duration) {
	key := "ctr"
	t0 := time.Now()
	for i := 0; i < cnt; i++ {
		client.Get(key)
	}
	delta = time.Now().Sub(t0)
	client.Flushdb()
	return
}
示例#6
0
func flushAndQuitOnCompletion(t *testing.T, client redis.Client) {
	// flush it
	e := client.Flushdb()
	if e != nil {
		t.Errorf("on Flushdb - %s", e)
	}
	e = client.Quit()
	if e != nil {
		t.Errorf("on Quit - %s", e)
	}
}
示例#7
0
func doSet(client redis.Client, cnt int) (delta int64) {
	key := "ctr"
	value := strings.Bytes("foo")
	t0 := time.Nanoseconds()
	for i := 0; i < cnt; i++ {
		client.Set(key, value)
	}
	delta = time.Nanoseconds() - t0
	client.Flushdb()
	return
}
示例#8
0
func doSadd(client redis.Client, cnt int) (delta time.Duration) {
	key := "set"
	value := []byte("one")
	t0 := time.Now()
	for i := 0; i < cnt; i++ {
		client.Sadd(key, value)
	}
	delta = time.Now().Sub(t0)
	client.Flushdb()
	return
}
示例#9
0
func doSadd(client redis.Client, cnt int) (delta int64) {
	key := "set"
	value := []byte("one")
	t0 := time.Nanoseconds()
	for i := 0; i < cnt; i++ {
		client.Sadd(key, value)
	}
	delta = time.Nanoseconds() - t0
	client.Flushdb()
	return
}