cap limit, cache key contains limit
This commit is contained in:
10
main.go
10
main.go
@@ -164,6 +164,12 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
|
||||
limit = 4
|
||||
}
|
||||
|
||||
if limit > 10 {
|
||||
log.Infof("[GPM] limit out of bounds: %d", limit)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
tPlayer, err := utils.GetPlayer(db, id, conf.Steam.APIKey, nil)
|
||||
if err != nil {
|
||||
log.Infof("[GP] Player not found: %+v", err)
|
||||
@@ -172,7 +178,7 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
metaStats := new(utils.MetaStatsResponse)
|
||||
err = rdc.Get(context.Background(), fmt.Sprintf(utils.SideMetaCacheKey, tPlayer.ID), &metaStats)
|
||||
err = rdc.Get(context.Background(), fmt.Sprintf(utils.SideMetaCacheKey, tPlayer.ID, limit), &metaStats)
|
||||
if err != nil {
|
||||
metaStats, err = utils.GetMetaStats(tPlayer, db.Lock, limit)
|
||||
if err != nil {
|
||||
@@ -183,7 +189,7 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
err = rdc.Set(&cache.Item{
|
||||
Ctx: context.Background(),
|
||||
Key: fmt.Sprintf(utils.SideMetaCacheKey, tPlayer.ID),
|
||||
Key: fmt.Sprintf(utils.SideMetaCacheKey, tPlayer.ID, limit),
|
||||
Value: metaStats,
|
||||
TTL: time.Hour * 24 * 30,
|
||||
})
|
||||
|
@@ -196,7 +196,7 @@ type (
|
||||
|
||||
const (
|
||||
shareCodeURLEntry = "https://api.steampowered.com/ICSGOPlayers_730/GetNextMatchSharingCode/v1?key=%s&steamid=%d&steamidkey=%s&knowncode=%s"
|
||||
SideMetaCacheKey = "csgowtfd_side_meta_%d"
|
||||
SideMetaCacheKey = "csgowtfd_side_meta_%d_%d"
|
||||
MatchMetaCacheKey = "csgowtfd_match_meta_%d"
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user