MCPcopy Index your code
hub / github.com/larksuite/cli / RefreshCache

Function RefreshCache

internal/update/update.go:94–110  ·  view source on GitHub ↗

RefreshCache fetches the latest version from npm and updates the local cache. No-op if the cache is still fresh (< 24h). Safe to call from a goroutine.

(currentVersion string)

Source from the content-addressed store, hash-verified

92// RefreshCache fetches the latest version from npm and updates the local cache.
93// No-op if the cache is still fresh (< 24h). Safe to call from a goroutine.
94func RefreshCache(currentVersion string) {
95 if shouldSkip(currentVersion) {
96 return
97 }
98 state, _ := loadState()
99 if state != nil && time.Since(time.Unix(state.CheckedAt, 0)) < cacheTTL {
100 return // cache is fresh
101 }
102 latest, err := fetchLatestVersion()
103 if err != nil {
104 return
105 }
106 _ = saveState(&updateState{
107 LatestVersion: latest,
108 CheckedAt: time.Now().Unix(),
109 })
110}
111
112func shouldSkip(version string) bool {
113 if os.Getenv("LARKSUITE_CLI_NO_UPDATE_NOTIFIER") != "" {

Callers 2

setupNoticesFunction · 0.92
TestRefreshCacheFunction · 0.85

Calls 4

loadStateFunction · 0.85
fetchLatestVersionFunction · 0.85
saveStateFunction · 0.85
shouldSkipFunction · 0.70

Tested by 1

TestRefreshCacheFunction · 0.68