mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-18 04:40:03 +02:00
redis/wrapper.go: make "prefix" variable internal and provide SetPrefix() function
This commit is contained in:
parent
c1cdf50975
commit
cd9dd6468a
2 changed files with 8 additions and 3 deletions
2
main.go
2
main.go
|
|
@ -211,7 +211,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
redis.Prefix += chainInfo.ChainID.String() + "."
|
redis.SetPrefix("ship", chainInfo.ChainID.String())
|
||||||
|
|
||||||
if conf.StartBlockNum == config.NULL_BLOCK_NUMBER {
|
if conf.StartBlockNum == config.NULL_BLOCK_NUMBER {
|
||||||
if conf.IrreversibleOnly {
|
if conf.IrreversibleOnly {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ var redis_pipe _redis.Pipeliner
|
||||||
|
|
||||||
var redisCtx = context.Background()
|
var redisCtx = context.Background()
|
||||||
|
|
||||||
var Prefix = "ship."
|
var prefix []string
|
||||||
|
|
||||||
func Connect(addr string, password string, db int) error {
|
func Connect(addr string, password string, db int) error {
|
||||||
rdb = _redis.NewClient(&_redis.Options{
|
rdb = _redis.NewClient(&_redis.Options{
|
||||||
|
|
@ -32,8 +32,13 @@ func Client() *_redis.Client {
|
||||||
return rdb
|
return rdb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetPrefix(components ...string) {
|
||||||
|
prefix = components
|
||||||
|
}
|
||||||
|
|
||||||
func Key(components ...string) string {
|
func Key(components ...string) string {
|
||||||
return Prefix + strings.Join(components, ".")
|
components = append(prefix, components...)
|
||||||
|
return strings.Join(components, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Get(key string) *_redis.StringCmd {
|
func Get(key string) *_redis.StringCmd {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue