MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / GetAuthCache

Function GetAuthCache

cmd/ttn-lw-cli/internal/util/cache.go:162–179  ·  view source on GitHub ↗

GetAuthCache gets the auth cache form the cache file.

()

Source from the content-addressed store, hash-verified

160
161// GetAuthCache gets the auth cache form the cache file.
162func GetAuthCache() (cache AuthCache, err error) {
163 cacheFile := cacheFile()
164 if cacheFile == "" {
165 return cache, nil
166 }
167 f, err := os.OpenFile(cacheFile, os.O_RDONLY, 0)
168 if err != nil {
169 if os.IsNotExist(err) {
170 return cache, nil
171 }
172 return cache, err
173 }
174 defer f.Close() // ignore errors
175 if err = json.NewDecoder(f).Decode(&cache.data); err != nil {
176 return cache, err
177 }
178 return cache, nil
179}
180
181// SaveAuthCache saves the auth cache to the cache file.
182func SaveAuthCache(cache AuthCache) (err error) {

Callers 1

preRunFunction · 0.92

Calls 4

cacheFileFunction · 0.85
NewDecoderMethod · 0.80
CloseMethod · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected