backend/pkg/permission/domain/redis.go

43 lines
940 B
Go
Raw Normal View History

2025-10-03 08:38:12 +00:00
package domain
import "strings"
2025-10-06 08:28:39 +00:00
const (
TicketKeyPrefix = "tic/"
)
const (
ClientDataKey = "permission:clients"
)
2025-10-03 08:38:12 +00:00
type RedisKey string
const (
2025-10-06 08:28:39 +00:00
AccessTokenRedisKey RedisKey = "access_token"
RefreshTokenRedisKey RedisKey = "refresh_token"
DeviceTokenRedisKey RedisKey = "device_token"
UIDTokenRedisKey RedisKey = "uid_token"
TicketRedisKey RedisKey = "ticket"
DeviceUIDRedisKey RedisKey = "device_uid"
2025-10-03 08:38:12 +00:00
)
func (key RedisKey) ToString() string {
2025-10-06 08:28:39 +00:00
return "permission:" + string(key)
2025-10-03 08:38:12 +00:00
}
func (key RedisKey) With(s ...string) RedisKey {
parts := append([]string{string(key)}, s...)
return RedisKey(strings.Join(parts, ":"))
}
2025-10-06 08:28:39 +00:00
func GetAccessTokenRedisKey(id string) string {
return AccessTokenRedisKey.With(id).ToString()
2025-10-03 08:38:12 +00:00
}
2025-10-06 08:28:39 +00:00
func GetUIDTokenRedisKey(uid string) string {
return UIDTokenRedisKey.With(uid).ToString()
2025-10-03 08:38:12 +00:00
}
2025-10-06 08:28:39 +00:00
func GetTicketRedisKey(ticket string) string {
return TicketRedisKey.With(ticket).ToString()
}