@@ -0,0 +1,688 @@
|
||||
package redisconst
|
||||
|
||||
import (
|
||||
"91porn-server/common/crypt"
|
||||
"91porn-server/common/timeutil"
|
||||
"91porn-server/common/timeutil/timerange"
|
||||
"91porn-server/models/s/statrecordmod"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const (
|
||||
Db0ExpiredChannel = "__keyevent@0__:expired"
|
||||
|
||||
userTokenFmt = "token:user:%d"
|
||||
UserTokenExpire = time.Hour
|
||||
|
||||
imSDKUserTokenFmt = "im:sdk:userToken:%d" // IM SDK 用户 token 缓存(按 imUserID)
|
||||
IMSDKUserTokenExpire = 12 * time.Hour
|
||||
|
||||
imSDKEnsureLockFmt = "im:sdk:ensure:lock:%d" // EnsureSDKUser 按 uid 加锁,防并发重复注册
|
||||
|
||||
IMSDKAppTokenKey = "im:sdk:appToken" // IM SDK appToken 缓存(内存 L1 + redis L2)
|
||||
|
||||
MobileCaptchaMaxCountInMinute = 1 // 1分钟内同一手机号只能发送一次验证码
|
||||
MobileCaptchaMaxCountInHour = 5 // 1小时内同一手机号只能发送五次验证码
|
||||
MobileCaptchaMaxCountInDay = 10 // 1天内同一手机号只能发送十次验证码
|
||||
mobileCaptchaFmt = "captcha:mobile:%s"
|
||||
MobileCaptchaExpire = 5 * time.Minute
|
||||
|
||||
smsCaptchaIPFmt = "sms:captcha:ip:%s"
|
||||
smsCaptchaUIDFmt = "sms:captcha:uid:%d"
|
||||
smsCaptchaPhoneNumberFmt = "sms:captcha:number:%s" // sms:captcha:number:mobile:xxx 用于统计手机号发送验证码的次数
|
||||
smsCaptchaUIDCooldownFmt = "sms:captcha:uid:cd:%d"
|
||||
SMSCaptchaUIDCooldown = 1 * time.Minute
|
||||
|
||||
emailCaptchaFmt = "captcha:email:%s"
|
||||
EmailCaptchaExpire = 5 * time.Minute
|
||||
|
||||
traderChatCacheFmt = "trader:cache:%d:%d"
|
||||
TraderChatCacheExpire = 2 * time.Minute
|
||||
|
||||
withdrawCfgFmt = "withdraw:cache:cfg"
|
||||
WithdrawCfgExpire = 8 * time.Hour
|
||||
|
||||
withdrawTariffFmt = "withdraw:tariff"
|
||||
WithdrawTariffExpire = 8 * time.Hour
|
||||
|
||||
webTokenFmt = "token:%s:%s" //token:admin:xxx, token:channel:xxx
|
||||
WebTokenExpire = 10 * time.Hour
|
||||
|
||||
visitLogsFmt = "visitlogs:%s" //visitlog:20301020
|
||||
|
||||
visitFmt = "visitFmt:%s" //统计访问频率
|
||||
VisitExpireMax = 1 * time.Hour
|
||||
|
||||
registFmt = "registFmt:%s" //用户注册频率
|
||||
RegistExpireMax = 1 * time.Hour
|
||||
|
||||
rankFmt = "rankFmt:%s"
|
||||
RankExpireMax = 20 * time.Minute
|
||||
|
||||
toneFmt = "toneFmt"
|
||||
ToneExpireMax = 20 * time.Minute
|
||||
|
||||
ipLocationFmt = "ip:city:%s" //ip:city:124.168.1.0.248 缓存ip
|
||||
IPLocationExpireMax = 24 * time.Hour
|
||||
|
||||
ipBlockFmt = "ip:block:%s" // ip:block:comment 用于存放限制发表评论的ip
|
||||
IPBlockExpire = 7 * 24 * time.Hour
|
||||
|
||||
ipAutoBlockFmt = "ip:auto:%s:%s" // ip:block:comment 用于自动限制基于IP的接口访问
|
||||
autoBlockFmt = "auto:%s:%d" // ip:block:comment 用于自动限制基于次数的接口访问
|
||||
|
||||
dataCachFmt = "data:%s:%s" //visitlog:20301020:uid
|
||||
DataCachExpire = time.Minute * 2
|
||||
|
||||
m3u8CacheFmt = "video:m3u8:%s" //video:m3u8:b0ac9b27eec64abebfc4c65cc4b89d03 m3u8键 //用于缓存添加相对的路径的m3u8文件
|
||||
m3u8PureCacheFmt = "video:m3u8:pure:%s" //video:m3u8:b0ac9b27eec64abebfc4c65cc4b89d03 m3u8键 //用于缓存原生的m3u8文件
|
||||
m3u8H5CacheFmt = "video:m3u8:h5:%s" //video:m3u8:b0ac9b27eec64abebfc4c65cc4b89d03 m3u8键 //用于缓存原生的m3u8文件
|
||||
M3u8CacheExpire = 1 * time.Hour
|
||||
|
||||
m3u8HourlyCountFmt = "m3u8:hourly:count:%d" // 每用户每小时 m3u8 请求次数
|
||||
M3u8HourlyCountExpire = 1 * time.Hour
|
||||
|
||||
// M3u8H5RefererSet H5 m3u8 请求来源计数(Redis ZSet):member=来源 scheme://host(Referer 缺省回退 Origin),
|
||||
// score=累计请求次数。ZScore 查单个来源总数,ZRevRangeWithScores 看 Top 来源;每天凌晨 5 点(Asia/Shanghai)
|
||||
// 过期清零、从零重新累计(刷回时 EXPIREAT 到下一个 5 点,见 updownctrl.FlushM3u8RefererStats)。
|
||||
M3u8H5RefererSet = "m3u8:h5:referer"
|
||||
|
||||
CdnCacheKey = "cdn:cache:url" //cdn域名缓存
|
||||
CdnCacheExpire = 2 * time.Minute
|
||||
|
||||
NewRegisterBehaFmt = "user:new:register:%d" //用户行为记录
|
||||
NewRegisterBehaCountFmt = "user:new:register:%d:%s" //用户行为次数记录
|
||||
NotifyKeyFmt = "notify:user:new:register:%d" //过期键通知
|
||||
NotifyKeyExpire = 20 * time.Minute //专门设置的通知键
|
||||
NewRegisterBehaExpire = 30 * time.Minute //用户
|
||||
NewRegisterBehaCountExpire = 30 * time.Minute //用户
|
||||
|
||||
replayNonceFmt = "replay:nonce:%s" //接口调用sign值
|
||||
|
||||
tagGroup = "taggroup"
|
||||
TagGroupExpireMax = time.Minute
|
||||
|
||||
DailyConsumeReward = "dailyConsumeReward:"
|
||||
|
||||
PayableAgentsKey = "payableAgents"
|
||||
PayableAgentsExpire = 5 * time.Minute
|
||||
|
||||
MarqueeKey = "marquee"
|
||||
|
||||
playLeaderboardKey = "leaderboard:play:%s:%d"
|
||||
playLeaderboardKeyExpire = 24 * time.Hour
|
||||
|
||||
NameSource = "name:source" //姓名池
|
||||
NameSourceExpire = 2 * 24 * time.Hour
|
||||
|
||||
AdNewsListKeyFmt = "video:news:ad:%d" //广告ID列表
|
||||
AdNewsListKeyExpire = time.Hour
|
||||
|
||||
LandDomainCacheKey = "domain:land" //落地页/推广域名 Key
|
||||
LandDomainCacheExpire = 2 * time.Hour
|
||||
|
||||
userInfo = "user:info:%d"
|
||||
userInfoExpire = 20 * time.Minute
|
||||
|
||||
tagInfo = "tag:info:%s"
|
||||
tagInfoExpire = 20 * time.Minute
|
||||
|
||||
videoInfo = "video:info:%s"
|
||||
videoInfoExpire = 30 * time.Minute
|
||||
|
||||
newestNews = "newest:news:%s"
|
||||
newestNewsExpire = 5 * time.Minute
|
||||
|
||||
userRechargeLimit = "userRechargeLimit:%d" //token:admin:xxx, token:channel:xxx
|
||||
userRechargeLimitExpire = 6 * time.Second
|
||||
|
||||
userReqLimit = "userRechargeLimit:%d:%s" //token:admin:xxx, token:channel:xxx
|
||||
userReqLimitExpire = 1 * time.Second
|
||||
|
||||
userWithdrawLimit = "userWithdrawimit:%d" //userWithdrawimit:xxx
|
||||
userWithdrawLimitExpire = 60 * time.Second
|
||||
|
||||
promotionCodeSetKey = "promotion_code_set" //推广码set key值
|
||||
|
||||
userLikeRateLimitKey = "userLike:%d"
|
||||
userLikeRateLimitExpire = 6 * time.Second
|
||||
|
||||
userBuyVidRateLimitKey = "userBuyVid:%d"
|
||||
userBuyVidRateLimitExpire = 6 * time.Second
|
||||
|
||||
initialPopKey = "vid:initialPopularity"
|
||||
|
||||
tagSortVidKey = "tagSortVid:%s:%v:%v:%d:%d"
|
||||
tagSortVidExpire = 30 * time.Minute
|
||||
|
||||
userCollectionKey = "vid:userCollection:%d:%d:%d:%s:%d"
|
||||
userCollectionExpire = 5 * time.Minute
|
||||
|
||||
vidPageViewListKey = "vidPageViewList:%d"
|
||||
vidPageViewListExpire = 30 * time.Minute
|
||||
|
||||
waliPlayerMacSet = "waliPlayerMacSet:%s"
|
||||
waliPlayerMacExpire = 24 * 7 * time.Hour
|
||||
waliPlayerGlobalID = "waliPlayerGlobalIDSet:%s"
|
||||
waliPlayerGlobalIDExpire = 24 * 7 * time.Hour
|
||||
waliPlayerIP = "waliPlayerIPSet:%s"
|
||||
waliPlayerIPExpire = 24 * time.Hour
|
||||
|
||||
WithdrawOrderKey = "withdraw:order:processing" // 提现处于审核中的用户
|
||||
WithdrawOrderDuration = 15 * time.Minute // 过滤用户窗口时间
|
||||
|
||||
RedsyncUserKey = "redsync:user:%d" // 用户维度分布式锁
|
||||
AiMateLoginLockKey = "redsync:ai-mate-login:%d"
|
||||
AiFundLockKey = "redsync:ai-fund:%d"
|
||||
RedsyncUserExpiration = 10 * time.Second // 用户维度分布式锁过期时间
|
||||
|
||||
ContentUpdateMarkersCache = "content:update-markers:v1"
|
||||
ContentUpdateMarkersCacheExpire = 30 * time.Second
|
||||
|
||||
CenterAdvertiseCache = "centerAdvertiseCache" // 数据中心广告缓存
|
||||
CenterVersionCache = "centerVersionCache:%s:%s:%s:%s" // 数据中心版本缓存
|
||||
|
||||
VidAdKey = "video:ad" //广告ID列表
|
||||
VidAdKeyExpire = time.Minute * 2
|
||||
|
||||
active2023RedisKey = "active_2023:%d"
|
||||
active2023Expired = time.Minute
|
||||
|
||||
// 幸福广场缓存
|
||||
ImageTopKey = "imageTop:filter:%d"
|
||||
ImageTopExpire = time.Minute * 5
|
||||
|
||||
userDailyTaskRewardLockKey = "userDailyTask:%d:%s"
|
||||
userDailyTaskRewardLockExpire = time.Minute
|
||||
|
||||
// 缓存用户每日完成数量. 比如点击了x次广告
|
||||
userDailyTaskCountKey = "userDailyTaskCount:%d:%d:%s"
|
||||
|
||||
// 缓存用户每日领取奖励次数.
|
||||
userDailyTaskRewardTimeKey = "userDailyTaskRewardTime:%d:%d:%s"
|
||||
|
||||
// 缓存用户一次性任务完成情况
|
||||
userOnceTaskCompleteKey = "userOnceTaskComplete:%d:%d"
|
||||
userOnceTaskCompleteExpire = time.Hour * 24
|
||||
ModulesCache = "modulesCache" // 模块缓存
|
||||
dailyTaskCacheFmt = "dailyTask:%v:%v:%v" // 每日任务缓存
|
||||
InviteCache = "inviteCache:uid:%v" // 推广数据缓存
|
||||
PublishTagInfoCache = "publishTagInfoCache" // 发布标签缓存
|
||||
ModuleVideoInfoCache = "moduleVideoInfoCache:mid:%v:%v:%v:%v:%v:%v" // 视频模块缓存
|
||||
SectionVideoInfoCache = "sectionVideoInfoCache:mid:%v:sortType:%v:pageSize:%v:pageNumber:%v" // 视频模块缓存
|
||||
AIModCache = "aiModCache" // AI模版缓存
|
||||
GetAwVipInfo = "getAwVipInfo" // AWVip信息缓存
|
||||
checkApiKeyFmt = "checkApi:ip:%s:api:%s:s:%v" // 接口调用
|
||||
SensitiveWordsCache = "sensitiveWordsCache" // 敏感词库缓存
|
||||
GameAdvanceCache = "gameAdvanceCache:%v" // 游戏预售缓存
|
||||
AdvanceCache = "hj_advanceCache:%v" // 预售缓卡存
|
||||
CheckApiKeyExpire = 1 * time.Minute
|
||||
RecommendVip = "RecommendVip" // VIP推荐展示
|
||||
RecommendVipExpire = 2 * time.Minute
|
||||
DiscountArea = "DiscountArea" // 折扣专区列表缓存
|
||||
DiscountAreaExpire = 2 * time.Minute
|
||||
shortVideoListCache = "shortDiscoverList:types:%d:tagId:%s:page:%v_%v" // 短视频发现模块数据换粗
|
||||
ShortVideoListCacheExpire = time.Minute * 10 // 短视频发现模块数据换粗
|
||||
|
||||
mediaTagInfoExpire = 20 * time.Minute
|
||||
mediaTagInfo = "mediaTag:info:%s" // 动漫标签缓存
|
||||
acgBrowseCountListKey = "acgBrowseCountList:%d"
|
||||
MediaLibraryInfo = "mediaLibraryInfo:info" // 动漫片库缓存
|
||||
ShortVideosKey = "short-videos-all-ids-list" // ShortVideosKey 短视频ID列表 - 用于推荐
|
||||
VideoLibraryCache = "videoLibraryCache" // 片库缓存
|
||||
ShortVideosRecoCacheKey = "shortVideosRecoCache" // 短视频-推荐 ID列表 - 用于短视频推荐
|
||||
followUpUsersAndSHORTKey = "follow:%d:SHORT:%d_%d"
|
||||
|
||||
mostNewModuleVideoListKey = "mostNewModuleVideoList:%v:%v:%v" // 91porn 首页最新视频列表缓存key
|
||||
MostNewModuleVideoListExpire = time.Minute * 10
|
||||
|
||||
MonitorCacheKey = "rs_monitorCache" // 监控缓存
|
||||
MonitorExpired = time.Minute * 4
|
||||
|
||||
OfficialWebsiteBasicDataCacheKey = "officialWebsiteBasicDataCache" // 官方网站基础数据缓存
|
||||
OfficialWebsiteBasicDataCacheExpire = time.Minute * 10
|
||||
OfficialWebsiteAlbumListCacheKey = "officialWebsiteAlbumListCache:%d:%d" // 官方网站专辑列表缓存
|
||||
OfficialWebsiteAlbumListCacheExpire = time.Minute * 10
|
||||
OfficialWebsiteHeroListCacheKey = "officialWebsiteHeroListCache:%d:%d:%d" // 官方网站演员列表缓存
|
||||
OfficialWebsiteHeroListCacheExpire = time.Minute * 10
|
||||
OfficialWebsiteVideoListCacheKey = "officialWebsiteVideoListCache:%d:%s:%d:%d:%d" // 官方网站视频列表缓存
|
||||
OfficialWebsiteVideoListCacheExpire = time.Minute * 10
|
||||
OfficialWebsiteNewsListCacheKey = "officialWebsiteNewsListCache:%d:%d" // 官方网站资讯列表缓存
|
||||
OfficialWebsiteNewsListCacheExpire = time.Minute * 10
|
||||
OfficialWebsitePartnerListCacheKey = "officialWebsitePartnerListCache" // 官方网站合作伙伴列表缓存
|
||||
OfficialWebsitePartnerListCacheExpire = time.Minute * 10
|
||||
)
|
||||
|
||||
const (
|
||||
NavigateRecreationCache = "navigateRecreationCache" // 导航站娱乐广告缓存
|
||||
UserPaymentStatusPopupCache = "UserPaymentStatusPopup" // 用户分层弹窗配置缓存
|
||||
)
|
||||
|
||||
const (
|
||||
aiFreeUndressTodayUseTimes = "aiFreeUndressTodayUseTimes:%v"
|
||||
)
|
||||
const (
|
||||
JanGangQuCacheKey = "jingangqu"
|
||||
JanGangQuCacheExpire = 10 * time.Minute
|
||||
)
|
||||
const (
|
||||
rankingListCacheKey = "ranking:%v:%v:%d:%d"
|
||||
hotRankingListCacheKey = "hotRanking:%v:%v:%v"
|
||||
RankingListCacheExpire = 10 * time.Minute
|
||||
)
|
||||
|
||||
// 渠道订阅的 消息体
|
||||
type RecommedPayload struct {
|
||||
UID uint64 `json:"uid"`
|
||||
City string `json:"city"`
|
||||
Page int `json:"page"`
|
||||
}
|
||||
|
||||
func GetFollowUpUsersAndSHORTKey(uid uint64, pageSize, pageNumber uint64) (string, time.Duration) {
|
||||
return fmt.Sprintf(followUpUsersAndSHORTKey, uid, pageSize, pageNumber), time.Minute * 10
|
||||
}
|
||||
|
||||
func GetMonitorCacheExpired() time.Duration {
|
||||
return MonitorExpired
|
||||
}
|
||||
|
||||
func AcgBrowseCountListKey(timestamp int64) string {
|
||||
return fmt.Sprintf(acgBrowseCountListKey, timestamp)
|
||||
}
|
||||
|
||||
func MediaTagInfoExpire() time.Duration {
|
||||
return mediaTagInfoExpire
|
||||
}
|
||||
|
||||
func MediaTagInfoKey(tid string) string {
|
||||
return fmt.Sprintf(mediaTagInfo, tid)
|
||||
}
|
||||
|
||||
func AiFreeUndressTodayUseTimesKey(uid uint64) string {
|
||||
return fmt.Sprintf(aiFreeUndressTodayUseTimes, uid)
|
||||
}
|
||||
|
||||
func UserTokenKey(uid uint64) string {
|
||||
return fmt.Sprintf(userTokenFmt, uid)
|
||||
}
|
||||
|
||||
// IMSDKUserTokenKey IM SDK 用户 token 缓存 key(按 imUserID)
|
||||
func IMSDKUserTokenKey(imUserID int64) string {
|
||||
return fmt.Sprintf(imSDKUserTokenFmt, imUserID)
|
||||
}
|
||||
|
||||
// IMSDKEnsureLockKey EnsureSDKUser 并发注册锁 key(按 uid)
|
||||
func IMSDKEnsureLockKey(uid uint64) string {
|
||||
return fmt.Sprintf(imSDKEnsureLockFmt, uid)
|
||||
}
|
||||
|
||||
func GameAdvanceKey(uid uint64) string {
|
||||
return fmt.Sprintf(GameAdvanceCache, uid)
|
||||
}
|
||||
|
||||
func AdvanceKey(uid uint64) string {
|
||||
return fmt.Sprintf(AdvanceCache, uid)
|
||||
}
|
||||
|
||||
// InviteCacheKey 推广数据
|
||||
func InviteCacheKey(uid uint64) string {
|
||||
return fmt.Sprintf(InviteCache, uid)
|
||||
}
|
||||
|
||||
func CheckApiKey(ip, apiPath string, second time.Time) string {
|
||||
return fmt.Sprintf(checkApiKeyFmt, ip, apiPath, second)
|
||||
}
|
||||
|
||||
// SectionVideoInfoCacheKey 模块视频Key
|
||||
func SectionVideoInfoCacheKey(sid string, sortType string, pageSize, pageNumber int64) string {
|
||||
return fmt.Sprintf(SectionVideoInfoCache, sid, sortType, pageSize, pageNumber)
|
||||
}
|
||||
|
||||
func DailyTaskCacheKey(uid uint64, taskType any, today time.Time) string {
|
||||
return fmt.Sprintf(dailyTaskCacheFmt, taskType, uid, today)
|
||||
}
|
||||
|
||||
func MobileCaptchaKey(mobile string) string {
|
||||
return fmt.Sprintf(mobileCaptchaFmt, mobile)
|
||||
}
|
||||
|
||||
func SMSCaptchaIPKey(ip string) string {
|
||||
return fmt.Sprintf(smsCaptchaIPFmt, ip)
|
||||
}
|
||||
|
||||
func SMSCaptchaIPExpire() time.Duration {
|
||||
year, month, day := time.Now().Date()
|
||||
return time.Until(time.Date(year, month, day+1, 0, 0, 0, 0, time.Local))
|
||||
}
|
||||
|
||||
func SMSCaptchaUIDKey(uid uint64) string {
|
||||
return fmt.Sprintf(smsCaptchaUIDFmt, uid)
|
||||
}
|
||||
|
||||
func SMSCaptchaUIDCooldownKey(uid uint64) string {
|
||||
return fmt.Sprintf(smsCaptchaUIDCooldownFmt, uid)
|
||||
}
|
||||
|
||||
func SMSCaptchaPhoneNumberKey(mobile string) string {
|
||||
return fmt.Sprintf(smsCaptchaPhoneNumberFmt, mobile)
|
||||
}
|
||||
|
||||
func WebTokenKey(typ string, act string) string {
|
||||
return fmt.Sprintf(webTokenFmt, typ, act)
|
||||
}
|
||||
|
||||
func UserAdNewsListKey(uid uint64) string {
|
||||
return fmt.Sprintf(AdNewsListKeyFmt, uid)
|
||||
}
|
||||
|
||||
func VisitKey(t time.Time) string {
|
||||
recentMinute := timerange.RecentMinute(t, statrecordmod.FiveMinuteScale) //对齐本次统计时间 Minute % frequency == 0
|
||||
return fmt.Sprintf(visitFmt, recentMinute.Format("200601021504"))
|
||||
}
|
||||
|
||||
func RegistKey(t time.Time) string {
|
||||
recentMinute := timerange.RecentMinute(t, statrecordmod.FiveMinuteScale) //对齐本次统计时间 Minute % frequency == 0
|
||||
return fmt.Sprintf(registFmt, recentMinute.Format("200601021504"))
|
||||
}
|
||||
|
||||
func NotifyKey(uid uint64) string {
|
||||
return fmt.Sprintf(NotifyKeyFmt, uid)
|
||||
}
|
||||
|
||||
func RegistBehaviorKey(uid uint64) string {
|
||||
return fmt.Sprintf(NewRegisterBehaFmt, uid)
|
||||
}
|
||||
|
||||
func RegistBehaviorCountKey(uid uint64, req string) string {
|
||||
return fmt.Sprintf(NewRegisterBehaCountFmt, uid, req)
|
||||
}
|
||||
|
||||
func RankKey(rankType string) string {
|
||||
return fmt.Sprintf(rankFmt, rankType)
|
||||
}
|
||||
|
||||
func ToneKey() string {
|
||||
return toneFmt
|
||||
}
|
||||
|
||||
func UserVisitLogsKey(t time.Time) string {
|
||||
return fmt.Sprintf(visitLogsFmt, t.Format("20060102"))
|
||||
}
|
||||
|
||||
func UserVisitLogExpire(now time.Time) time.Duration {
|
||||
return timeutil.BeginningOfTomorrow(now).Sub(now) + 5*time.Minute
|
||||
}
|
||||
|
||||
func IpLocationFmt(ip string) string {
|
||||
return fmt.Sprintf(ipLocationFmt, ip)
|
||||
}
|
||||
|
||||
func M3u8CacheFmt(m3u8 string) string {
|
||||
return fmt.Sprintf(m3u8CacheFmt, m3u8)
|
||||
}
|
||||
|
||||
func M3u8PureCacheFmt(m3u8 string) string {
|
||||
return fmt.Sprintf(m3u8PureCacheFmt, m3u8)
|
||||
}
|
||||
func M3u8H5CacheFmt(m3u8 string) string {
|
||||
return fmt.Sprintf(m3u8H5CacheFmt, m3u8)
|
||||
}
|
||||
|
||||
func M3u8HourlyCountKey(uid uint64) string {
|
||||
return fmt.Sprintf(m3u8HourlyCountFmt, uid)
|
||||
}
|
||||
func UserInfoKey() string {
|
||||
return userInfo
|
||||
}
|
||||
func TagInfoKey() string {
|
||||
return tagInfo
|
||||
}
|
||||
func VideoInfoKey() string {
|
||||
return videoInfo
|
||||
}
|
||||
|
||||
func UserInfoExpire() time.Duration {
|
||||
return userInfoExpire
|
||||
}
|
||||
func TagInfoExpire() time.Duration {
|
||||
return tagInfoExpire
|
||||
}
|
||||
func VideoInfoExpire() time.Duration {
|
||||
return videoInfoExpire
|
||||
}
|
||||
func DataCachKey(db string, m string) string {
|
||||
return fmt.Sprintf(dataCachFmt, db, m)
|
||||
}
|
||||
|
||||
func IPBlockKey(blockType string) string {
|
||||
return fmt.Sprintf(ipBlockFmt, blockType)
|
||||
}
|
||||
|
||||
func IPAutoBlockKey(blockType, ip string) string {
|
||||
return fmt.Sprintf(ipAutoBlockFmt, blockType, ip)
|
||||
}
|
||||
|
||||
func AutoBlockKey(blockType string, uid uint64) string {
|
||||
return fmt.Sprintf(autoBlockFmt, blockType, uid)
|
||||
}
|
||||
|
||||
func ReplayNonceKey(nonce string) string {
|
||||
return fmt.Sprintf(replayNonceFmt, nonce)
|
||||
}
|
||||
|
||||
func TagGroup() string {
|
||||
return tagGroup
|
||||
}
|
||||
|
||||
func TraderChatCacheKey(uid uint64, proT int) string {
|
||||
return fmt.Sprintf(traderChatCacheFmt, uid, proT)
|
||||
}
|
||||
|
||||
func WithdrawCfgCacheKey() string {
|
||||
return withdrawCfgFmt
|
||||
}
|
||||
|
||||
func WithdrawTariffCacheKey() string {
|
||||
return withdrawTariffFmt
|
||||
}
|
||||
|
||||
func NewestNewsKey(t time.Time) string {
|
||||
return fmt.Sprintf(newestNews, t.String())
|
||||
}
|
||||
|
||||
func NewestNewsKey_old() string {
|
||||
return "newest:news"
|
||||
}
|
||||
|
||||
func NewestShortVideoKey() string {
|
||||
return "newest:shortvideo"
|
||||
}
|
||||
|
||||
func NewestNewsExpire() time.Duration {
|
||||
return newestNewsExpire
|
||||
}
|
||||
|
||||
func RechargeLimtKey(uid uint64) string {
|
||||
return fmt.Sprintf(userRechargeLimit, uid)
|
||||
}
|
||||
func RechargeLimtKeyExpire() time.Duration {
|
||||
return userRechargeLimitExpire
|
||||
}
|
||||
func WithdrawLimtKey() string {
|
||||
return userWithdrawLimit
|
||||
}
|
||||
func WithdrawLimtKeyExpire() time.Duration {
|
||||
return userWithdrawLimitExpire
|
||||
}
|
||||
func PromotionCodeKey() string {
|
||||
return promotionCodeSetKey
|
||||
}
|
||||
func WaLiIPSetKey(ip string) string {
|
||||
return fmt.Sprintf(waliPlayerIP, ip)
|
||||
}
|
||||
func WaLiIPSetExpire() time.Duration {
|
||||
return waliPlayerIPExpire
|
||||
}
|
||||
func WaLiMacSetKey(mac string) string {
|
||||
return fmt.Sprintf(waliPlayerMacSet, mac)
|
||||
}
|
||||
func WaLiMacSetExpire() time.Duration {
|
||||
return waliPlayerMacExpire
|
||||
}
|
||||
func WaLiDevSetKey(dev string) string {
|
||||
return fmt.Sprintf(waliPlayerGlobalID, dev)
|
||||
}
|
||||
func WaLiDevSetExpire() time.Duration {
|
||||
return waliPlayerGlobalIDExpire
|
||||
}
|
||||
|
||||
func GetRedsyncUserKey(uid uint64) string {
|
||||
return fmt.Sprintf(RedsyncUserKey, uid)
|
||||
}
|
||||
|
||||
func GetAiMateLoginLockKey(uid uint64) string {
|
||||
return fmt.Sprintf(AiMateLoginLockKey, uid)
|
||||
}
|
||||
|
||||
func GetAiFundLockKey(uid uint64) string {
|
||||
return fmt.Sprintf(AiFundLockKey, uid)
|
||||
}
|
||||
|
||||
func GetUserLikeRateLimitKey() string {
|
||||
return userLikeRateLimitKey
|
||||
}
|
||||
|
||||
func GetUserLikeRateLimitExpire() time.Duration {
|
||||
return userLikeRateLimitExpire
|
||||
}
|
||||
|
||||
func GetEmailCaptchaKey(email string) string {
|
||||
return fmt.Sprintf(emailCaptchaFmt, email)
|
||||
}
|
||||
|
||||
func GetUserBuyVidRateLimitKey() string {
|
||||
return userBuyVidRateLimitKey
|
||||
}
|
||||
|
||||
func GetUserBuyVidRateLimitExpire() time.Duration {
|
||||
return userBuyVidRateLimitExpire
|
||||
}
|
||||
|
||||
func GetInitialVideoPopularityKey() string {
|
||||
return initialPopKey
|
||||
}
|
||||
|
||||
func GetTagSortVideoKey(tid string, newsType string, sort int, skip, limit uint64) string {
|
||||
return fmt.Sprintf(tagSortVidKey, newsType, tid, sort, skip, limit)
|
||||
}
|
||||
func GetTagSortVideoExpire() time.Duration {
|
||||
return tagSortVidExpire
|
||||
}
|
||||
func ReqLimtKey(uid uint64, m string) string {
|
||||
return fmt.Sprintf(userReqLimit, uid, m)
|
||||
}
|
||||
func ReqLimtKeyExpire() time.Duration {
|
||||
return userReqLimitExpire
|
||||
}
|
||||
func UserCollectionKey(uid uint64, pageNum, pageSize uint64, playTimeType int, sortType string) string {
|
||||
return fmt.Sprintf(userCollectionKey, uid, pageNum, pageSize, sortType, playTimeType)
|
||||
}
|
||||
func UserCollectionExpire() time.Duration {
|
||||
return userCollectionExpire
|
||||
}
|
||||
|
||||
func VidPageViewListKey(timestamp int64) string {
|
||||
return fmt.Sprintf(vidPageViewListKey, timestamp)
|
||||
}
|
||||
func VidPageViewListExpire() time.Duration {
|
||||
return vidPageViewListExpire
|
||||
}
|
||||
|
||||
func GetUserActive2023RedisKey(uid uint64) string {
|
||||
return fmt.Sprintf(active2023RedisKey, uid)
|
||||
}
|
||||
|
||||
func GetUserActive2023Expred() time.Duration {
|
||||
return active2023Expired
|
||||
}
|
||||
|
||||
func GetVersionRedisKey(a, b, c, d string) string {
|
||||
return fmt.Sprintf(CenterVersionCache, a, b, c, d)
|
||||
}
|
||||
|
||||
func PlayLeaderboardKey(rT string, timestamp int64) string {
|
||||
return fmt.Sprintf(playLeaderboardKey, rT, timestamp)
|
||||
}
|
||||
func PlayLeaderboardKeyExpire() time.Duration {
|
||||
return playLeaderboardKeyExpire
|
||||
}
|
||||
|
||||
func GetUserDailyTaskRewardLockKey(uid uint64, taskId string) string {
|
||||
return fmt.Sprintf(userDailyTaskRewardLockKey, uid, taskId)
|
||||
}
|
||||
|
||||
func GetUserDailyTaskRewardLockExpired() time.Duration {
|
||||
return userDailyTaskRewardLockExpire
|
||||
}
|
||||
|
||||
// 缓存用户每日完成数量. 比如点击了x次广告
|
||||
func GetUserDailyTaskCountKey(uid uint64, taskType int64) string {
|
||||
return fmt.Sprintf(userDailyTaskCountKey, uid, taskType, time.Now().Format("2006-01-02"))
|
||||
}
|
||||
|
||||
// 缓存用户每日领取奖励次数.
|
||||
func GetUserDailyTaskRewardTimeKey(uid uint64, taskType int64) string {
|
||||
return fmt.Sprintf(userDailyTaskRewardTimeKey, uid, taskType, time.Now().Format("2006-01-02"))
|
||||
}
|
||||
|
||||
func GetUserDailyTaskExpired() time.Duration {
|
||||
year, month, day := time.Now().Date()
|
||||
return time.Until(time.Date(year, month, day+1, 0, 1, 0, 0, time.Local)) // 多缓存1分钟
|
||||
}
|
||||
|
||||
// 用户一次性任务是否完成. value: 0 未完成; 1 已完成
|
||||
func GetUserOnceTaskCompleteKey(uid uint64, taskType int64) string {
|
||||
return fmt.Sprintf(userOnceTaskCompleteKey, uid, taskType)
|
||||
}
|
||||
|
||||
func GetUserOnceTaskCompleteExpired() time.Duration {
|
||||
return userOnceTaskCompleteExpire
|
||||
}
|
||||
|
||||
const (
|
||||
videoShareList = "videoShareList"
|
||||
videoShareExpired = time.Minute * 10
|
||||
)
|
||||
|
||||
func GetVideoShareListKey() string {
|
||||
return videoShareList
|
||||
}
|
||||
|
||||
func GetVideoShareListExpired() time.Duration {
|
||||
return videoShareExpired
|
||||
}
|
||||
|
||||
func GetShortVideoListCacheKey(types int, tid string, page, pagesize uint64) string {
|
||||
return fmt.Sprintf(shortVideoListCache, types, tid, page, pagesize)
|
||||
}
|
||||
|
||||
func GetRankingListExpired() time.Duration {
|
||||
return RankingListCacheExpire
|
||||
}
|
||||
func GetRankingListCacheKey(v ...any) string {
|
||||
return fmt.Sprintf(rankingListCacheKey, v...)
|
||||
}
|
||||
|
||||
func GetHotRankingListCacheKey(tagIds []primitive.ObjectID, pageNumber, pageSize uint64) string {
|
||||
b, _ := json.Marshal(tagIds)
|
||||
md5Str := crypt.ByteToMd5(b)
|
||||
return fmt.Sprintf(hotRankingListCacheKey, md5Str, pageNumber, pageSize)
|
||||
}
|
||||
|
||||
func GetMostNewModuleVideoListKey(sortType int, page, pageSize uint64) string {
|
||||
return fmt.Sprintf(mostNewModuleVideoListKey, sortType, page, pageSize)
|
||||
}
|
||||
Reference in New Issue
Block a user