39 lines
859 B
Go
39 lines
859 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"
|
|
)
|
|
|
|
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()
|
|
}
|