BL star endpoint actually gets cached???

This commit is contained in:
Liam 2022-10-20 18:36:26 +01:00
parent 253cd4a103
commit 14602dc11a
2 changed files with 9 additions and 9 deletions

@ -15,11 +15,10 @@ export default async function handler(req, res) {
const difficulty = req.query.difficulty.replace(" ", ""); const difficulty = req.query.difficulty.replace(" ", "");
const characteristic = req.query.characteristic; const characteristic = req.query.characteristic;
const exists = await RedisUtils.exists(`${KEY}${mapHash}`); const key = `${KEY}${difficulty}-${characteristic}-${mapHash}`;
const exists = await RedisUtils.exists(key);
if (exists) { if (exists) {
const data = await RedisUtils.getValue( const data = await RedisUtils.getValue(key);
`${KEY}${difficulty}-${characteristic}-${mapHash}`.replace(" ", "")
);
res.setHeader("Cache-Status", "hit"); res.setHeader("Cache-Status", "hit");
return res.status(200).json({ return res.status(200).json({
@ -46,10 +45,7 @@ export default async function handler(req, res) {
}); });
} }
const json = await data.json(); const json = await data.json();
RedisUtils.setValue( RedisUtils.setValue(key, json.difficulty.stars);
`${KEY}${difficulty}-${characteristic}-${mapHash}`.replace(" ", ""),
json.difficulty.stars
);
res.setHeader("Cache-Status", "miss"); res.setHeader("Cache-Status", "miss");
return res.status(200).json({ return res.status(200).json({
status: "OK", status: "OK",

@ -26,9 +26,13 @@ export default class ScoreStats extends Component {
data.percentage.replace("%", ""), data.percentage.replace("%", ""),
data.websiteType data.websiteType
); );
if (this.lastKnownPP === undefined || this.lastKnownPP < currentPP) { if (this.lastKnownPP === undefined) {
this.lastKnownPP = currentPP;
}
if (currentPP < this.lastKnownPP || currentPP === undefined) {
currentPP = this.lastKnownPP; currentPP = this.lastKnownPP;
} }
this.lastKnownPP = currentPP;
return ( return (
<div className={styles.scoreStats}> <div className={styles.scoreStats}>