1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

redis/wrapper.go: make "prefix" variable internal and provide SetPrefix() function

This commit is contained in:
Henrik Hautakoski 2022-11-29 05:55:13 +01:00
parent c1cdf50975
commit cd9dd6468a
2 changed files with 8 additions and 3 deletions

View file

@ -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 {

View file

@ -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 {