redis_store.go 998 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package redis_lua
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/filer"
  4. "github.com/chrislusf/seaweedfs/weed/util"
  5. "github.com/go-redis/redis/v8"
  6. )
  7. func init() {
  8. filer.Stores = append(filer.Stores, &RedisLuaStore{})
  9. }
  10. type RedisLuaStore struct {
  11. UniversalRedisLuaStore
  12. }
  13. func (store *RedisLuaStore) GetName() string {
  14. return "redis_lua"
  15. }
  16. func (store *RedisLuaStore) Initialize(configuration util.Configuration, prefix string) (err error) {
  17. return store.initialize(
  18. configuration.GetString(prefix+"address"),
  19. configuration.GetString(prefix+"password"),
  20. configuration.GetInt(prefix+"database"),
  21. configuration.GetStringSlice(prefix+"superLargeDirectories"),
  22. )
  23. }
  24. func (store *RedisLuaStore) initialize(hostPort string, password string, database int, superLargeDirectories []string) (err error) {
  25. store.Client = redis.NewClient(&redis.Options{
  26. Addr: hostPort,
  27. Password: password,
  28. DB: database,
  29. })
  30. store.loadSuperLargeDirectories(superLargeDirectories)
  31. return
  32. }