keys.go 948 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
package user_k

import (
	"fmt"
	"git.hilo.cn/hilo-common/resource/mysql"
	"hilo-group/_const/redis_key"
)

const (
	UserPrefix             = "user:"
	UserTinyInfoStr        = UserPrefix + "tiny:${userId}"           // value:json(cv.CvUserTiny)
	UserExternalIdToUIdStr = UserPrefix + "externalId:${externalId}" // value:userId
	UserCodeToUIdStr       = UserPrefix + "code:${externalId}"       // value:userId
	UserTradeUnionIds      = "user:trade:union:ids"                  // type:string,value json(uids)
)

// 获取用户简要信息缓存key
func GetUserTinyKey(userId mysql.ID) string {
	return redis_key.ReplaceKey(UserTinyInfoStr, fmt.Sprintf("%d", userId))
}

// 获取externalId到userId
func GetExternalIdToUidKey(externalId mysql.Str) string {
	return redis_key.ReplaceKey(UserExternalIdToUIdStr, externalId)
}

// 获取code到userId
func GetCodeToUidKey(code mysql.Str) string {
	return redis_key.ReplaceKey(UserCodeToUIdStr, code)
}