disable cache for now
This commit is contained in:
parent
2ebc04243c
commit
392f7c0db8
@ -5,7 +5,6 @@ import { getAverageColor } from "@/common/image-utils";
|
||||
import { LeaderboardData } from "@/components/leaderboard/leaderboard-data";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import ScoreSaberLeaderboardScoresPageToken from "@ssr/common/types/token/scoresaber/score-saber-leaderboard-scores-page-token";
|
||||
import NodeCache from "node-cache";
|
||||
import ScoreSaberLeaderboardToken from "@ssr/common/types/token/scoresaber/score-saber-leaderboard-token";
|
||||
|
||||
const UNKNOWN_LEADERBOARD = {
|
||||
@ -28,8 +27,6 @@ type LeaderboardData = {
|
||||
page: number;
|
||||
};
|
||||
|
||||
const leaderboardCache = new NodeCache({ stdTTL: 60, checkperiod: 120 });
|
||||
|
||||
/**
|
||||
* Gets the leaderboard data and scores
|
||||
*
|
||||
@ -42,24 +39,17 @@ const getLeaderboardData = async ({ params }: Props, fetchScores: boolean = true
|
||||
const id = slug[0]; // The leaderboard id
|
||||
const page = parseInt(slug[1]) || 1; // The page number
|
||||
|
||||
const cacheId = `${id}-${page}`;
|
||||
if (leaderboardCache.has(cacheId)) {
|
||||
return leaderboardCache.get(cacheId) as LeaderboardData;
|
||||
}
|
||||
|
||||
const leaderboard = await scoresaberService.lookupLeaderboard(id);
|
||||
let scores: ScoreSaberLeaderboardScoresPageToken | undefined;
|
||||
if (fetchScores) {
|
||||
scores = await scoresaberService.lookupLeaderboardScores(id + "", page);
|
||||
}
|
||||
|
||||
const leaderboardData = {
|
||||
return {
|
||||
page: page,
|
||||
leaderboard: leaderboard,
|
||||
scores: scores,
|
||||
};
|
||||
leaderboardCache.set(cacheId, leaderboardData);
|
||||
return leaderboardData;
|
||||
};
|
||||
|
||||
export async function generateMetadata(props: Props): Promise<Metadata> {
|
||||
|
@ -35,8 +35,6 @@ type PlayerData = {
|
||||
search: string;
|
||||
};
|
||||
|
||||
const playerCache = new NodeCache({ stdTTL: 60, checkperiod: 120 });
|
||||
|
||||
/**
|
||||
* Gets the player data and scores
|
||||
*
|
||||
@ -51,11 +49,6 @@ const getPlayerData = async ({ params }: Props, fetchScores: boolean = true): Pr
|
||||
const page = parseInt(slug[2]) || 1; // The page number
|
||||
const search = (slug[3] as string) || ""; // The search query
|
||||
|
||||
const cacheId = `${id}-${sort}-${page}-${search}`;
|
||||
if (playerCache.has(cacheId)) {
|
||||
return playerCache.get(cacheId) as PlayerData;
|
||||
}
|
||||
|
||||
const playerToken = await scoresaberService.lookupPlayer(id);
|
||||
const player =
|
||||
playerToken && (await getScoreSaberPlayerFromToken(playerToken, config.siteApi, cookies().get("playerId")?.value));
|
||||
@ -69,15 +62,13 @@ const getPlayerData = async ({ params }: Props, fetchScores: boolean = true): Pr
|
||||
});
|
||||
}
|
||||
|
||||
const playerData = {
|
||||
return {
|
||||
sort: sort,
|
||||
page: page,
|
||||
search: search,
|
||||
player: player,
|
||||
scores: scores,
|
||||
};
|
||||
playerCache.set(cacheId, playerData);
|
||||
return playerData;
|
||||
};
|
||||
|
||||
export async function generateMetadata(props: Props): Promise<Metadata> {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { config } from "../../config";
|
||||
import { cache } from "react";
|
||||
|
||||
/**
|
||||
* Proxies all non-localhost images to make them load faster.
|
||||
|
Reference in New Issue
Block a user