diff --git a/analytics/cmd/service/run.go b/analytics/cmd/service/run.go index 9d3fcc68e..d5b7233c6 100644 --- a/analytics/cmd/service/run.go +++ b/analytics/cmd/service/run.go @@ -203,7 +203,7 @@ func newNotionalCache( redisClient := redis.NewClient(&redis.Options{Addr: cfg.CacheURL}) // get notional cache client and init load to local cache - notionalCache, err := wormscanNotionalCache.NewNotionalCache(ctx, redisClient, cfg.CacheChannel, logger) + notionalCache, err := wormscanNotionalCache.NewNotionalCache(ctx, redisClient, cfg.CachePrefix, cfg.CacheChannel, logger) if err != nil { return nil, fmt.Errorf("failed to create notional cache client: %w", err) } diff --git a/analytics/config/config.go b/analytics/config/config.go index 528fd27a7..981364995 100644 --- a/analytics/config/config.go +++ b/analytics/config/config.go @@ -29,6 +29,7 @@ type Configuration struct { PprofEnabled bool `env:"PPROF_ENABLED,default=false"` P2pNetwork string `env:"P2P_NETWORK,required"` CacheURL string `env:"CACHE_URL,required"` + CachePrefix string `env:"CACHE_PREFIX,required"` CacheChannel string `env:"CACHE_CHANNEL,required"` } diff --git a/api/main.go b/api/main.go index f1f651189..87cd6d234 100644 --- a/api/main.go +++ b/api/main.go @@ -242,7 +242,7 @@ func NewCache(ctx context.Context, cfg *config.AppConfig, logger *zap.Logger) (w cacheClient, _ := wormscanCache.NewCacheClient(redisClient, cfg.Cache.Enabled, cfg.Cache.Prefix, logger) // get notional cache client and init load to local cache - notionalCache, _ := wormscanNotionalCache.NewNotionalCache(ctx, redisClient, cfg.Cache.Channel, logger) + notionalCache, _ := wormscanNotionalCache.NewNotionalCache(ctx, redisClient, cfg.Cache.Prefix, cfg.Cache.Channel, logger) notionalCache.Init(ctx) return cacheClient, notionalCache diff --git a/common/client/cache/notional/cache.go b/common/client/cache/notional/cache.go index f381fd5be..4ac94508e 100644 --- a/common/client/cache/notional/cache.go +++ b/common/client/cache/notional/cache.go @@ -56,7 +56,7 @@ type NotionalCache struct { // NewNotionalCache create a new cache client. // After create a NotionalCache use the Init method to initialize pubsub and load the cache. -func NewNotionalCache(ctx context.Context, redisClient *redis.Client, channel string, log *zap.Logger) (*NotionalCache, error) { +func NewNotionalCache(ctx context.Context, redisClient *redis.Client, prefix string, channel string, log *zap.Logger) (*NotionalCache, error) { if redisClient == nil { return nil, errors.New("redis client is nil") } @@ -67,7 +67,7 @@ func NewNotionalCache(ctx context.Context, redisClient *redis.Client, channel st pubSub: pubsub, channel: channel, notionalMap: sync.Map{}, - prefix: "", + prefix: prefix, logger: log}, nil } diff --git a/deploy/analytics/analytics-service.yaml b/deploy/analytics/analytics-service.yaml index 0dbe954bc..85aaeb9a6 100644 --- a/deploy/analytics/analytics-service.yaml +++ b/deploy/analytics/analytics-service.yaml @@ -98,6 +98,11 @@ spec: configMapKeyRef: name: config key: redis-uri + - name: CACHE_PREFIX + valueFrom: + configMapKeyRef: + name: config + key: redis-prefix resources: limits: memory: {{ .RESOURCES_LIMITS_MEMORY }} diff --git a/deploy/api/api-service.yaml b/deploy/api/api-service.yaml index 4297c6f3e..ccbbeb55c 100644 --- a/deploy/api/api-service.yaml +++ b/deploy/api/api-service.yaml @@ -69,7 +69,7 @@ spec: valueFrom: configMapKeyRef: name: config - key: redis-uri + key: redis-prefix - name: WORMSCAN_DB_URL valueFrom: secretKeyRef: @@ -89,7 +89,7 @@ spec: valueFrom: configMapKeyRef: name: config - key: redis-uri + key: redis-prefix - name: WORMSCAN_CACHE_ENABLED value: "true" - name: WORMSCAN_CACHE_CHANNEL diff --git a/deploy/common/configmap.yaml b/deploy/common/configmap.yaml index 0f54a79cb..39727a805 100644 --- a/deploy/common/configmap.yaml +++ b/deploy/common/configmap.yaml @@ -12,4 +12,5 @@ data: influxdb-organization: {{ .INFLUX_ORGANIZATION }} influxdb-bucket-infinite: {{ .INFLUX_BUCKET_INFINITE }} influxdb-bucket-30-days: {{ .INFLUX_BUCKET_30_DAYS }} - influxdb-bucket-24-hours: {{ .INFLUX_BUCKET_24_HOURS }} \ No newline at end of file + influxdb-bucket-24-hours: {{ .INFLUX_BUCKET_24_HOURS }} + influx-bucket: {{ .INFLUX_BUCKET }}