MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / readCache

Function readCache

util/api_key_helper.go:38–54  ·  view source on GitHub ↗

readCache reads the cached API key from credstore.

(helperCmd string)

Source from the content-addressed store, hash-verified

36
37// readCache reads the cached API key from credstore.
38func readCache(helperCmd string) (*apiKeyCache, error) {
39 key := helperCacheKey(helperCmd)
40 val, err := GetCredential(key)
41 if err != nil {
42 return nil, err
43 }
44 if val == "" {
45 return nil, nil //nolint:nilnil // nil cache indicates cache miss, not an error
46 }
47
48 var cache apiKeyCache
49 if err := json.Unmarshal([]byte(val), &cache); err != nil {
50 return nil, err
51 }
52
53 return &cache, nil
54}
55
56// writeCache writes the API key cache to credstore.
57func writeCache(helperCmd, apiKey string) error {

Callers 1

Calls 2

helperCacheKeyFunction · 0.85
GetCredentialFunction · 0.85

Tested by

no test coverage detected