Cache tweaks
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import type {PageServerLoad} from "./$types";
|
||||
import getStars from "$lib/getStars";
|
||||
|
||||
const CACHE_LIFE = 1000 * 60 * 5
|
||||
|
||||
let lastRequest = Date.now()
|
||||
let starCount: number
|
||||
let starCount: number | null = null
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
const now = Date.now()
|
||||
const CACHE_LIFE = 1000 * 60 * 5
|
||||
|
||||
if (now - CACHE_LIFE > lastRequest || starCount === undefined) {
|
||||
if (now - CACHE_LIFE > lastRequest || starCount === null) {
|
||||
lastRequest = Date.now()
|
||||
try {
|
||||
starCount = await getStars('anatolykopyl')
|
||||
|
||||
Reference in New Issue
Block a user