app-cloudep-product-service/pkg/domain/redis.go

44 lines
1004 B
Go

package domain
import "strings"
type RedisKey string
func (key RedisKey) ToString() string {
return "product:" + string(key)
}
func (key RedisKey) With(s ...string) RedisKey {
parts := append([]string{string(key)}, s...)
return RedisKey(strings.Join(parts, ":"))
}
const (
GetProductRedisKey RedisKey = "get"
GetProductItemRedisKey RedisKey = "get_item"
GetProductStatisticsRedisKey RedisKey = "statistics"
GetTagsRedisKey RedisKey = "tags"
CategoryRedisKey RedisKey = "category"
)
func GetProductRK(id string) string {
return GetProductRedisKey.With(id).ToString()
}
func GetProductItemRK(id string) string {
return GetProductItemRedisKey.With(id).ToString()
}
func GetProductStatisticsRK(id string) string {
return GetProductStatisticsRedisKey.With(id).ToString()
}
func GetTagsRK(id string) string {
return GetTagsRedisKey.With(id).ToString()
}
func GetCategoryRedisKey(id string) string {
return CategoryRedisKey.With(id).ToString()
}