redigo memo
メモ
package main import ( "fmt" "github.com/garyburd/redigo/redis" ) func main() { c, err := redis.Dial("tcp", ":6379") if err != nil { panic(err) } defer c.Close() c.Do("FLUSHALL") c.Do("RPUSH", "list-key", "item1") c.Do("RPUSH", "list-key", "item2") c.Do("RPUSH", "list-key", "item3") c.Do("SADD", "set-key", "item1") c.Do("SADD", "set-key", "item2") c.Do("SADD", "set-key", "item3") c.Do("HSET", "hash-key", "sub-key1", "value1") c.Do("HSET", "hash-key", "sub-key2", "value2") c.Do("HSET", "hash-key", "sub-key3", "value3") c.Do("ZADD", "zset-key", 728, "member1") c.Do("ZADD", "zset-key", 982, "member0") list, err := redis.Strings(c.Do("LRANGE", "list-key", 0, -1)) if err != nil { fmt.Println(err) } fmt.Println(list) set, err := redis.Strings(c.Do("SMEMBERS", "set-key")) if err != nil { fmt.Println(err) } fmt.Println(set) hash, err := redis.Strings(c.Do("HGETALL", "hash-key")) if err != nil { fmt.Println(err) } fmt.Println(hash) zset, err := redis.Strings(c.Do("ZRANGE", "zset-key", 0, -1, "withscores")) if err != nil { fmt.Println(err) } fmt.Println(zset) zset2, err := redis.Strings(c.Do("ZRANGEBYSCORE", "zset-key", 0, 800, "withscores")) if err != nil { fmt.Println(err) } fmt.Println(zset2) }