MCPcopy Index your code
hub / github.com/appleboy/CodeGPT / writeCache

Function writeCache

util/api_key_helper.go:57–70  ·  view source on GitHub ↗

writeCache writes the API key cache to credstore.

(helperCmd, apiKey string)

Source from the content-addressed store, hash-verified

55
56// writeCache writes the API key cache to credstore.
57func writeCache(helperCmd, apiKey string) error {
58 key := helperCacheKey(helperCmd)
59 cache := apiKeyCache{
60 APIKey: apiKey,
61 LastFetchTime: time.Now(),
62 }
63
64 data, err := json.Marshal(cache)
65 if err != nil {
66 return err
67 }
68
69 return SetCredential(key, string(data))
70}
71
72// needsRefresh checks if the cached key needs to be refreshed
73func needsRefresh(cache *apiKeyCache, refreshInterval time.Duration) bool {

Callers 1

Calls 2

helperCacheKeyFunction · 0.85
SetCredentialFunction · 0.85

Tested by

no test coverage detected