Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using context, and change from Error to debug and warn #115

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pkg/helpers/kvcachehelper/rediscache/rediscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ func NewRedisCache(redisDb redisdb.RedisDB) *RedisCache {

func (c *RedisCache) Set(ctx context.Context, key string, value string) {
if key == "" {
rlog.Error("Key is empty", nil)
rlog.Warnc(ctx, "Key is empty")
return
}
err := c.redisDb.Set(context.Background(), key, value)
err := c.redisDb.Set(ctx, key, value)
if err != nil {
rlog.Error(fmt.Sprintf("Error adding value to redis cache by key: %s", key), nil)
rlog.Debugc(ctx, fmt.Sprintf("Error adding value to redis cache by key: %s", key))
return
}
}

func (c *RedisCache) Get(ctx context.Context, key string) (string, bool) {
if key == "" {
rlog.Error("Key is empty", nil)
rlog.Warnc(ctx, "Key is empty")
return "", false
}
var cacheValue string
err := c.redisDb.Get(context.Background(), key, &cacheValue)
err := c.redisDb.Get(ctx, key, &cacheValue)
if err != nil {
rlog.Error(fmt.Sprintf("Error getting value from redis cache by key: %s", key), nil)
rlog.Debugc(ctx, fmt.Sprintf("Error getting value from redis cache by key: %s", key))
return "", false
}

Expand All @@ -52,12 +52,12 @@ func (c *RedisCache) Get(ctx context.Context, key string) (string, bool) {

func (c *RedisCache) Remove(ctx context.Context, key string) bool {
if key == "" {
rlog.Error("Key is empty", nil)
rlog.Warnc(ctx, "Key is empty")
return false
}
err := c.redisDb.Delete(context.Background(), key)
err := c.redisDb.Delete(ctx, key)
if err != nil {
rlog.Error(fmt.Sprintf("Error deleting value from redis cache by key: %s", key), nil)
rlog.Debugc(ctx, fmt.Sprintf("Error deleting value from redis cache by key: %s", key))
return false
}

Expand Down
Loading