MCPcopy Create free account
hub / github.com/cloudbase/garm / Get

Method Get

cache/tools_cache.go:48–66  ·  view source on GitHub ↗
(entityID string)

Source from the content-addressed store, hash-verified

46}
47
48func (g *GithubToolsCache) Get(entityID string) ([]commonParams.RunnerApplicationDownload, error) {
49 g.mux.Lock()
50 defer g.mux.Unlock()
51
52 if cache, ok := g.entities[entityID]; ok {
53 if cache.entity.Credentials.ForgeType == params.GithubEndpointType {
54 if time.Now().UTC().After(cache.expiresAt.Add(-5 * time.Minute)) {
55 // Stale cache, remove it.
56 delete(g.entities, entityID)
57 return nil, fmt.Errorf("cache expired for entity %s", entityID)
58 }
59 }
60 if cache.err != nil {
61 return nil, cache.err
62 }
63 return cache.tools, nil
64 }
65 return nil, fmt.Errorf("no cache found for entity %s", entityID)
66}
67
68func (g *GithubToolsCache) Set(entity params.ForgeEntity, tools []commonParams.RunnerApplicationDownload) {
69 g.mux.Lock()

Callers 2

GetGithubToolsCacheFunction · 0.45
file_object.goFile · 0.45

Calls 3

AddMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected