Merged in feature/warmup (pull request #1887)
* unified warmup function Approved-by: Linus Flood
This commit is contained in:
@@ -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",
|
||||
}
|
||||
)
|
||||
}),
|
||||
}),
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user