diff --git a/main.go b/main.go index 290889b..7d21ce9 100644 --- a/main.go +++ b/main.go @@ -211,7 +211,7 @@ func main() { return } - redis.Prefix += chainInfo.ChainID.String() + "." + redis.SetPrefix("ship", chainInfo.ChainID.String()) if conf.StartBlockNum == config.NULL_BLOCK_NUMBER { if conf.IrreversibleOnly { diff --git a/redis/wrapper.go b/redis/wrapper.go index 7c450bf..e103ed4 100644 --- a/redis/wrapper.go +++ b/redis/wrapper.go @@ -14,7 +14,7 @@ var redis_pipe _redis.Pipeliner var redisCtx = context.Background() -var Prefix = "ship." +var prefix []string func Connect(addr string, password string, db int) error { rdb = _redis.NewClient(&_redis.Options{ @@ -32,8 +32,13 @@ func Client() *_redis.Client { return rdb } +func SetPrefix(components ...string) { + prefix = components +} + func Key(components ...string) string { - return Prefix + strings.Join(components, ".") + components = append(prefix, components...) + return strings.Join(components, ".") } func Get(key string) *_redis.StringCmd {