add redis prefix to communication channel (#651)

This commit is contained in:
gipsh 2023-08-22 15:24:14 -03:00 committed by GitHub
parent 0741ef7045
commit 3fa1804c1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -65,7 +65,7 @@ func NewNotionalCache(ctx context.Context, redisClient *redis.Client, prefix str
return &NotionalCache{
client: redisClient,
pubSub: pubsub,
channel: channel,
channel: formatChannel(prefix, channel),
notionalMap: sync.Map{},
prefix: prefix,
logger: log}, nil
@ -180,3 +180,10 @@ func (c *NotionalCache) renderKey(key string) string {
func (c *NotionalCache) renderRegExp() string {
return "*" + c.renderKey(wormscanNotionalCacheKeyRegex)
}
func formatChannel(prefix string, channel string) string {
if prefix != "" {
return fmt.Sprintf("%s:%s", prefix, channel)
}
return channel
}

View File

@ -28,7 +28,7 @@ func NewNotionalJob(api *coingecko.CoingeckoAPI, cacheClient *redis.Client, cach
coingeckoAPI: api,
cacheClient: cacheClient,
cachePrefix: cachePrefix,
cacheChannel: cacheChannel,
cacheChannel: formatChannel(cachePrefix, cacheChannel),
p2pNetwork: p2pNetwork,
logger: logger,
}