add support for redis cluster

fix https://github.com/chrislusf/seaweedfs/issues/705
This commit is contained in:
Chris Lu
2018-08-15 00:01:38 -07:00
parent 9b51ed7af2
commit 708acee502
4 changed files with 179 additions and 132 deletions

View File

@@ -0,0 +1,31 @@
package redis
import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/go-redis/redis"
)
func init() {
filer2.Stores = append(filer2.Stores, &RedisClusterStore{})
}
type RedisClusterStore struct {
UniversalRedisStore
}
func (store *RedisClusterStore) GetName() string {
return "redis_cluster"
}
func (store *RedisClusterStore) Initialize(configuration filer2.Configuration) (err error) {
return store.initialize(
configuration.GetStringSlice("addresses"),
)
}
func (store *RedisClusterStore) initialize(addresses []string) (err error) {
store.Client = redis.NewClusterClient(&redis.ClusterOptions{
Addrs: addresses,
})
return
}