Merged in feature/warmup (pull request #1887)

* unified warmup function

Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-04-29 06:18:14 +00:00
parent bbbd665a32
commit c1505ce50e
33 changed files with 886 additions and 185 deletions

View File

@@ -666,6 +666,7 @@ export const hotelQueryRouter = router({
lang: lang,
serviceToken: ctx.serviceToken,
})
return hotels
})
)
@@ -674,15 +675,14 @@ export const hotelQueryRouter = router({
return hotelData
}
if (warmup) {
return await fetchHotels()
}
const cacheClient = await getCacheClient()
return await cacheClient.cacheOrGet(
`${lang}:getDestinationsMapData`,
fetchHotels,
"max"
"max",
{
cacheStrategy: warmup ? "fetch-then-cache" : "cache-first",
}
)
}),
}),

View File

@@ -130,9 +130,11 @@ export async function getCity({
export async function getCountries({
lang,
serviceToken,
warmup = false,
}: {
lang: Lang
serviceToken: string
warmup?: boolean
}) {
const cacheClient = await getCacheClient()
return await cacheClient.cacheOrGet(
@@ -166,7 +168,10 @@ export async function getCountries({
return countries.data
},
"1d"
"1d",
{
cacheStrategy: warmup ? "fetch-then-cache" : "cache-first",
}
)
}