Esempio n. 1
1
func listConfig(client *redis.Client, key string) {
	value, err := client.Hgetall(key)

	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	for key, value := range value.StringMap() {
		fmt.Println(fmt.Sprintf("%s=%s", key, value))
	}
}
Esempio n. 2
0
func QuitClient(t *testing.T, client redis.Client) {
	// flush it
	e := client.Quit()
	if e != nil {
		t.Fatalf("on Quit - %s", e)
	}
}
Esempio n. 3
0
func doLpop(id string, signal chan int, client redis.Client, cnt int) {
	key := "list-L-" + id
	for i := 0; i < cnt; i++ {
		client.Lpop(key)
	}
	signal <- 1
}
Esempio n. 4
0
func doGet (id string, signal chan int, client redis.Client, cnt int)  {
	key := "set-" + id;
	for i:=0;i<cnt;i++ { 
		client.Get(key);
	}
	signal <- 1;
}
Esempio n. 5
0
func FlushClient(t *testing.T, client redis.Client) {
	// flush it
	e := client.Flushdb()
	if e != nil {
		t.Fatalf("on Flushdb - %s", e)
	}
}
Esempio n. 6
0
func doDecr (id string, signal chan int, client redis.Client, cnt int)  {
	key := "ctr-" + id;
	for i:=0;i<cnt;i++ { 
		client.Decr(key);
	}
	signal <- 1;
}
Esempio n. 7
0
func doRpop (id string, signal chan int, client redis.Client, cnt int)  {
	key := "list-R" + id;
	for i:=0;i<cnt;i++ { 
		client.Rpop(key);
	}
	signal <- 1;
}
Esempio n. 8
0
func doIncr(id string, signal chan int, client redis.Client, cnt int) {
	key := "ctr-" + id
	for i := 0; i < cnt; i++ {
		client.Incr(key)
	}
	signal <- 1
}
Esempio n. 9
0
func doSet (id string, signal chan int, client redis.Client, cnt int)  {
	key := "set-" + id;
	value := strings.Bytes("foo");
	for i:=0;i<cnt;i++ { 
		client.Set(key, value);
	}
	signal <- 1;
}
Esempio n. 10
0
func doRpush(id string, signal chan int, client redis.Client, cnt int) {
	key := "list-R-" + id
	value := []byte("foo")
	for i := 0; i < cnt; i++ {
		client.Rpush(key, value)
	}
	signal <- 1
}
Esempio n. 11
0
func doRpush (id string, signal chan int, client redis.Client, cnt int)  {
	key := "list-R-" + id;
	value := strings.Bytes("foo");
	for i:=0;i<cnt;i++ { 
		client.Rpush(key, value);
	}
	signal <- 1;
}
Esempio n. 12
0
func doSet(id string, signal chan int, client redis.Client, cnt int) {
	key := "set-" + id
	value := []byte("foo")
	for i := 0; i < cnt; i++ {
		client.Set(key, value)
	}
	signal <- 1
}
Esempio n. 13
0
func doLpush(id string, signal chan int, client redis.Client, cnt int) {
	key := "list-L-" + id
	value := strings.Bytes("foo")
	for i := 0; i < cnt; i++ {
		client.Lpush(key, value)
	}
	signal <- 1
}
Esempio n. 14
0
func removeConfig(client *redis.Client, key string, name string) {
	_, err := client.Hdel(key, name)

	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
Esempio n. 15
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
}
Esempio n. 16
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
}
Esempio n. 17
0
func doRpop(client redis.Client, cnt int) (delta time.Duration) {
	key := "list-R"
	t0 := time.Now()
	for i := 0; i < cnt; i++ {
		client.Lpop(key)
	}
	delta = time.Now().Sub(t0)
	return
}
Esempio n. 18
0
func doRpop(client redis.Client, cnt int) (delta int64) {
	key := "list-R"
	t0 := time.Nanoseconds()
	for i := 0; i < cnt; i++ {
		client.Lpop(key)
	}
	delta = time.Nanoseconds() - t0
	return
}
Esempio n. 19
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
}
Esempio n. 20
0
func doRpush(client redis.Client, cnt int) (delta int64) {
	key := "list-R"
	value := strings.Bytes("foo")
	t0 := time.Nanoseconds()
	for i := 0; i < cnt; i++ {
		client.Lpush(key, value)
	}
	delta = time.Nanoseconds() - t0
	return
}
Esempio n. 21
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
}
Esempio n. 22
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
}
Esempio n. 23
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
}
Esempio n. 24
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)
	}
}
Esempio n. 25
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
}
Esempio n. 26
0
func addConfig(client *redis.Client, key string, nameAndValue string) {
	parts := strings.Split(nameAndValue, "=")
	name := parts[0]
	value := strings.Join(parts[1:len(parts)], "=")
	_, err := client.Hset(key, name, value)

	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
Esempio n. 27
0
func run(client *redis.Client, key string, command string) {
	value, err := client.Hgetall(key)

	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(111)
	}

	env := make([]string, 0)

	for key, value := range value.StringMap() {
		env = append(env, fmt.Sprintf("%s=%s", key, value))
	}

	syscall.Exec("/bin/sh", []string{"/bin/sh", "-c", command}, env)
}
Esempio n. 28
0
func dump_db(port int, db int, output io.Writer) {
	var client redis.Client

	if port != 0 {
		client.Addr = "127.0.0.1:" + strconv.Itoa(port)
	}

	if db != 0 {
		client.Db = db
	}

	fmt.Fprintf(output, "FLUSHDB\r\n")

	keys, err := client.Keys("*")

	if err != nil {
		println("Redis-dump failed", err.Error())
		return
	}

	for _, key := range keys {
		typ, _ := client.Type(key)

		if typ == "string" {
			data, _ := client.Get(key)
			fmt.Fprintf(output, "SET %s %d\r\n%s\r\n", key, len(data), data)
		} else if typ == "list" {
			llen, _ := client.Llen(key)
			for i := 0; i < llen; i++ {
				data, _ := client.Lindex(key, i)
				fmt.Fprintf(output, "RPUSH %s %d\r\n%s\r\n", key, len(data), data)
			}
		} else if typ == "set" {
			members, _ := client.Smembers(key)
			for _, data := range members {
				fmt.Fprintf(output, "SADD %s %d\r\n%s\r\n", key, len(data), data)
			}
		}
	}

}
Esempio n. 29
0
func doPing (id string, signal chan int, client redis.Client, cnt int)  {
	for i:=0;i<cnt;i++ { 
		client.Ping();
	}
	signal <- 1;
}
Esempio n. 30
-1
func doRpush(client redis.Client, cnt int) (delta time.Duration) {
	key := "list-R"
	value := []byte("foo")
	t0 := time.Now()
	for i := 0; i < cnt; i++ {
		client.Lpush(key, value)
	}
	delta = time.Now().Sub(t0)
	return
}