2018-08-15 07:01:38 +00:00
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer2"
|
2018-08-19 22:17:55 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
2018-08-19 22:18:37 +00:00
|
|
|
"github.com/go-redis/redis"
|
2018-08-15 07:01:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
filer2.Stores = append(filer2.Stores, &RedisClusterStore{})
|
|
|
|
}
|
|
|
|
|
|
|
|
type RedisClusterStore struct {
|
|
|
|
UniversalRedisStore
|
|
|
|
}
|
|
|
|
|
|
|
|
func (store *RedisClusterStore) GetName() string {
|
|
|
|
return "redis_cluster"
|
|
|
|
}
|
|
|
|
|
2018-08-19 22:17:55 +00:00
|
|
|
func (store *RedisClusterStore) Initialize(configuration util.Configuration) (err error) {
|
2018-08-15 07:01:38 +00:00
|
|
|
return store.initialize(
|
|
|
|
configuration.GetStringSlice("addresses"),
|
2019-05-20 16:00:30 +00:00
|
|
|
configuration.GetString("password"),
|
2019-12-18 15:34:19 +00:00
|
|
|
configuration.GetBool("connection_use_read_only"),
|
|
|
|
configuration.GetBool("connection_route_by_latency"),
|
2018-08-15 07:01:38 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-12-18 15:34:19 +00:00
|
|
|
func (store *RedisClusterStore) initialize(addresses []string, password string, readOnly, routeByLatency bool) (err error) {
|
2018-08-15 07:01:38 +00:00
|
|
|
store.Client = redis.NewClusterClient(&redis.ClusterOptions{
|
2019-12-18 15:34:19 +00:00
|
|
|
Addrs: addresses,
|
|
|
|
Password: password,
|
|
|
|
ReadOnly: readOnly,
|
|
|
|
RouteByLatency: routeByLatency,
|
2018-08-15 07:01:38 +00:00
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|