(entityID string)
| 46 | } |
| 47 | |
| 48 | func (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 | |
| 68 | func (g *GithubToolsCache) Set(entity params.ForgeEntity, tools []commonParams.RunnerApplicationDownload) { |
| 69 | g.mux.Lock() |
no test coverage detected