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

29 lines
555 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"
)
func GetProductRK(id string) string {
return GetProductRedisKey.With(id).ToString()
}
func GetProductItemRK(id string) string {
return GetProductItemRedisKey.With(id).ToString()
}