コード例 #1
1
ファイル: redis-env.go プロジェクト: brynary/redis-env
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))
	}
}
コード例 #2
0
ファイル: support.go プロジェクト: aaudis/GoRedisSession
func QuitClient(t *testing.T, client redis.Client) {
	// flush it
	e := client.Quit()
	if e != nil {
		t.Fatalf("on Quit - %s", e)
	}
}
コード例 #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
}
コード例 #4
0
ファイル: gosynchclient.go プロジェクト: evangineer/Go-Redis
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;
}
コード例 #5
0
ファイル: support.go プロジェクト: aaudis/GoRedisSession
func FlushClient(t *testing.T, client redis.Client) {
	// flush it
	e := client.Flushdb()
	if e != nil {
		t.Fatalf("on Flushdb - %s", e)
	}
}
コード例 #6
0
ファイル: gosynchclient.go プロジェクト: evangineer/Go-Redis
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;
}
コード例 #7
0
ファイル: gosynchclient.go プロジェクト: evangineer/Go-Redis
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;
}
コード例 #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
}
コード例 #9
0
ファイル: gosynchclient.go プロジェクト: evangineer/Go-Redis
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;
}
コード例 #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
}
コード例 #11
0
ファイル: gosynchclient.go プロジェクト: evangineer/Go-Redis
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;
}
コード例 #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
}
コード例 #13
0
ファイル: gosynchclient.go プロジェクト: nono/Go-Redis
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
}
コード例 #14
0
ファイル: redis-env.go プロジェクト: brynary/redis-env
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)
	}
}
コード例 #15
0
ファイル: synchclient.go プロジェクト: evangineer/Go-Redis
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
}
コード例 #16
0
ファイル: synchclient.go プロジェクト: roolez/Go-Redis
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
}
コード例 #17
0
ファイル: synchclient.go プロジェクト: roolez/Go-Redis
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
}
コード例 #18
0
ファイル: synchclient.go プロジェクト: evangineer/Go-Redis
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
}
コード例 #19
0
ファイル: synchclient.go プロジェクト: evangineer/Go-Redis
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
}
コード例 #20
0
ファイル: synchclient.go プロジェクト: evangineer/Go-Redis
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
}
コード例 #21
0
ファイル: synchclient.go プロジェクト: roolez/Go-Redis
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
}
コード例 #22
0
ファイル: synchclient.go プロジェクト: evangineer/Go-Redis
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
}
コード例 #23
0
ファイル: synchclient.go プロジェクト: roolez/Go-Redis
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
}
コード例 #24
0
ファイル: sync_test.go プロジェクト: aaudis/GoRedisSession
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)
	}
}
コード例 #25
0
ファイル: synchclient.go プロジェクト: kpm/Go-Redis
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
}
コード例 #26
0
ファイル: redis-env.go プロジェクト: brynary/redis-env
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)
	}
}
コード例 #27
0
ファイル: redis-env.go プロジェクト: brynary/redis-env
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)
}
コード例 #28
0
ファイル: redis-dump.go プロジェクト: xinuxZ/goredis
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)
			}
		}
	}

}
コード例 #29
0
ファイル: gosynchclient.go プロジェクト: evangineer/Go-Redis
func doPing (id string, signal chan int, client redis.Client, cnt int)  {
	for i:=0;i<cnt;i++ { 
		client.Ping();
	}
	signal <- 1;
}
コード例 #30
-1
ファイル: synchclient.go プロジェクト: roolez/Go-Redis
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
}