keys.go 933 Bytes
Newer Older
chenweijian's avatar
chenweijian 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"
	"hilo-user/_const/redis_key"
	"hilo-user/resource/mysql"
)

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)
}