2025-03-17 02:08:22 +00:00
|
|
|
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 (
|
2025-03-19 11:28:07 +00:00
|
|
|
GetProductRedisKey RedisKey = "get"
|
|
|
|
GetProductItemRedisKey RedisKey = "get_item"
|
|
|
|
GetProductStatisticsRedisKey RedisKey = "statistics"
|
2025-03-20 09:11:56 +00:00
|
|
|
GetTagsRedisKey RedisKey = "tags"
|
2025-04-04 07:39:49 +00:00
|
|
|
CategoryRedisKey RedisKey = "category"
|
2025-03-17 02:08:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func GetProductRK(id string) string {
|
|
|
|
return GetProductRedisKey.With(id).ToString()
|
|
|
|
}
|
2025-03-19 06:45:44 +00:00
|
|
|
|
|
|
|
func GetProductItemRK(id string) string {
|
|
|
|
return GetProductItemRedisKey.With(id).ToString()
|
|
|
|
}
|
2025-03-19 11:28:07 +00:00
|
|
|
|
|
|
|
func GetProductStatisticsRK(id string) string {
|
|
|
|
return GetProductStatisticsRedisKey.With(id).ToString()
|
|
|
|
}
|
2025-03-20 09:11:56 +00:00
|
|
|
|
|
|
|
func GetTagsRK(id string) string {
|
|
|
|
return GetTagsRedisKey.With(id).ToString()
|
|
|
|
}
|
2025-04-04 07:39:49 +00:00
|
|
|
|
|
|
|
func GetCategoryRedisKey(id string) string {
|
|
|
|
return CategoryRedisKey.With(id).ToString()
|
|
|
|
}
|