adjust cache

This commit is contained in:
proddy
2025-03-02 17:44:53 +01:00
parent 44c4ee8bc0
commit 04ac3be242
2 changed files with 4 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ export const ACCESS_TOKEN = 'access_token';
export const alovaInstance = createAlova({ export const alovaInstance = createAlova({
statesHook: ReactHook, statesHook: ReactHook,
// timeout: 3000, // 3 seconds before throwing a timeout error, default is 0 = none // timeout: 3000, // 3 seconds before throwing a timeout error, default is 0 = none
cacheFor: null, // disable cache // cacheFor: null, // disable cache
// cacheFor: { // cacheFor: {
// GET: { // GET: {
// mode: 'memory', // mode: 'memory',

View File

@@ -14,8 +14,10 @@ export const updateLogSettings = (data: LogSettings) =>
export const fetchLogES = () => alovaInstance.Get('/es/log'); export const fetchLogES = () => alovaInstance.Get('/es/log');
// Get versions from GitHub // Get versions from GitHub
// cache for 10 minutes to stop getting the IP blocked by GitHub
export const getStableVersion = () => export const getStableVersion = () =>
alovaInstanceGH.Get('latest', { alovaInstanceGH.Get('latest', {
cacheFor: 60 * 10 * 1000,
transform(response: { data: { name: string; published_at: string } }) { transform(response: { data: { name: string; published_at: string } }) {
return { return {
name: response.data.name.substring(1), name: response.data.name.substring(1),
@@ -25,6 +27,7 @@ export const getStableVersion = () =>
}); });
export const getDevVersion = () => export const getDevVersion = () =>
alovaInstanceGH.Get('tags/latest', { alovaInstanceGH.Get('tags/latest', {
cacheFor: 60 * 10 * 1000,
transform(response: { data: { name: string; published_at: string } }) { transform(response: { data: { name: string; published_at: string } }) {
return { return {
name: response.data.name.split(/\s+/).splice(-1)[0].substring(1), name: response.data.name.split(/\s+/).splice(-1)[0].substring(1),