golangベースのredis clusterクライアント

2097 ワード

使用法


クラスタの導入と作成

import "github.com/gitstliu/go-redis-cluster"

cluster, err := redis.NewCluster(
    &redis.Options{
    StartNodes: []string{"127.0.0.1:7000", "127.0.0.1:7001", "127.0.0.1:7002"},
    ConnTimeout: 50 * time.Millisecond,
    ReadTimeout: 50 * time.Millisecond,
    WriteTimeout: 50 * time.Millisecond,
    KeepAlive: 16,
    AliveTime: 60 * time.Second,
    })

いくつかのコマンドを実行

cluster.Do("SET", "foo", "bar")
cluster.Do("INCR", "mycount", 1)
cluster.Do("LPUSH", "mylist", "foo", "bar")
cluster.Do("HMSET", "myhash", "f1", "foo", "f2", "bar")

GITHUB接続:https://github.com/gitstliu/go-redis-cluster