You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

  1. package redis2
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/filer"
  4. "github.com/chrislusf/seaweedfs/weed/util"
  5. "github.com/go-redis/redis"
  6. )
  7. func init() {
  8. filer.Stores = append(filer.Stores, &RedisCluster2Store{})
  9. }
  10. type RedisCluster2Store struct {
  11. UniversalRedis2Store
  12. }
  13. func (store *RedisCluster2Store) GetName() string {
  14. return "redis_cluster2"
  15. }
  16. func (store *RedisCluster2Store) Initialize(configuration util.Configuration, prefix string) (err error) {
  17. configuration.SetDefault(prefix+"useReadOnly", true)
  18. configuration.SetDefault(prefix+"routeByLatency", true)
  19. return store.initialize(
  20. configuration.GetStringSlice(prefix+"addresses"),
  21. configuration.GetString(prefix+"password"),
  22. configuration.GetBool(prefix+"useReadOnly"),
  23. configuration.GetBool(prefix+"routeByLatency"),
  24. configuration.GetStringSlice(prefix+"superLargeDirectories"),
  25. )
  26. }
  27. func (store *RedisCluster2Store) initialize(addresses []string, password string, readOnly, routeByLatency bool, superLargeDirectories []string) (err error) {
  28. store.Client = redis.NewClusterClient(&redis.ClusterOptions{
  29. Addrs: addresses,
  30. Password: password,
  31. ReadOnly: readOnly,
  32. RouteByLatency: routeByLatency,
  33. })
  34. store.loadSuperLargeDirectories(superLargeDirectories)
  35. return
  36. }