File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
1212 getUserInfo ,
1313 userHasAccessToWorkshop ,
1414} from '@epic-web/workshop-utils/epic-api.server'
15- import { checkForUpdates } from '@epic-web/workshop-utils/git.server'
15+ import { checkForUpdatesCached } from '@epic-web/workshop-utils/git.server'
1616import { makeTimings } from '@epic-web/workshop-utils/timing.server'
1717import {
1818 getSetClientIdCookieHeader ,
@@ -122,7 +122,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
122122 user : getUserInfo ( ) ,
123123 userHasAccess : userHasAccessToWorkshop ( { request, timings } ) ,
124124 apps : getApps ( { request, timings } ) ,
125- repoUpdates : checkForUpdates ( ) ,
125+ repoUpdates : checkForUpdatesCached ( ) ,
126126 unmutedNotifications : getUnmutedNotifications ( ) ,
127127 } )
128128
Original file line number Diff line number Diff line change 11import { spawn } from 'child_process'
22import {
3- checkForUpdates ,
3+ checkForUpdatesCached ,
44 updateLocalRepo ,
55} from '@epic-web/workshop-utils/git.server'
66import { json } from '@remix-run/node'
@@ -9,7 +9,7 @@ import { useEffect, useRef } from 'react'
99import { toast } from 'sonner'
1010
1111export async function action ( ) {
12- const updates = await checkForUpdates ( )
12+ const updates = await checkForUpdatesCached ( )
1313 if ( ! updates . updatesAvailable ) {
1414 return json ( { type : 'error' , error : 'No updates available' } as const , {
1515 status : 400 ,
Original file line number Diff line number Diff line change 88 init as initApps ,
99 setModifiedTimesForAppDirs ,
1010} from '@epic-web/workshop-utils/apps.server'
11- import { checkForUpdates } from '@epic-web/workshop-utils/git.server'
11+ import { checkForUpdatesCached } from '@epic-web/workshop-utils/git.server'
1212import { checkConnectionCached } from '@epic-web/workshop-utils/utils.server'
1313import { createRequestHandler } from '@remix-run/express'
1414import { type ServerBuild } from '@remix-run/node'
@@ -50,7 +50,7 @@ const epicshopAppRootDir = isRunningInBuildDir
5050 : path . join ( __dirname , '..' )
5151
5252// kick this off early...
53- const hasUpdatesPromise = checkForUpdates ( )
53+ const hasUpdatesPromise = checkForUpdatesCached ( )
5454// warm up some caches
5555void getApps ( )
5656void checkConnectionCached ( )
Original file line number Diff line number Diff line change 11import { execa , execaCommand } from 'execa'
22import { getWorkshopRoot } from './apps.server.js'
3+ import { cachified , checkForUpdatesCache } from './cache.server.js'
34import { getWorkshopConfig } from './config.server.js'
45import { getErrorMessage } from './utils.js'
56import { checkConnection } from './utils.server.js'
@@ -87,6 +88,17 @@ export async function checkForUpdates() {
8788 }
8889}
8990
91+ export async function checkForUpdatesCached ( ) {
92+ const key = 'checkForUpdates'
93+ return cachified ( {
94+ ttl : 1000 * 60 ,
95+ swr : 1000 * 60 * 60 * 24 ,
96+ key,
97+ getFreshValue : checkForUpdates ,
98+ cache : checkForUpdatesCache ,
99+ } )
100+ }
101+
90102export async function updateLocalRepo ( ) {
91103 const cwd = getWorkshopRoot ( )
92104 try {
You can’t perform that action at this time.
0 commit comments