Skip to content

Commit

Permalink
feat: update cache key generation to use configurable cache version
Browse files Browse the repository at this point in the history
  • Loading branch information
sundayonah committed Jan 29, 2025
1 parent 6298114 commit 9e07b06
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions routers/middleware/caching.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,17 @@ func NewCacheService(config config.RedisConfiguration) (*CacheService, error) {
}

func generateCacheKey(c *gin.Context) string {
// conf := config.RedisConfig()
conf := "v1"
conf := config.RedisConfig()
path := c.Request.URL.Path
switch {
case path == "/v1/currencies":
return fmt.Sprintf("%s:api:currencies:list", conf)
return fmt.Sprintf("%s:api:currencies:list", conf.CacheVersion)
case path == "/v1/pubkey":
return fmt.Sprintf("%s:api:aggregator:pubkey", conf)
return fmt.Sprintf("%s:api:aggregator:pubkey", conf.CacheVersion)
case len(c.Param("currency_code")) > 0:
return fmt.Sprintf("%s:api:institutions:%s", conf, c.Param("currency_code"))
return fmt.Sprintf("%s:api:institutions:%s", conf.CacheVersion, c.Param("currency_code"))
default:
return fmt.Sprintf("%s:api:%s", conf, path)
return fmt.Sprintf("%s:api:%s", conf.CacheVersion, path)
}
}

Expand Down

0 comments on commit 9e07b06

Please sign in to comment.