get returns the cached entry for name and whether it is still fresh (within detectionTTL). A stale or missing entry reports fresh=false so the caller knows to re-probe.
(name string)
| 77 | // (within detectionTTL). A stale or missing entry reports fresh=false so the |
| 78 | // caller knows to re-probe. |
| 79 | func (c *detectionCache) get(name string) (detectionEntry, bool) { |
| 80 | c.mu.RLock() |
| 81 | defer c.mu.RUnlock() |
| 82 | entry, ok := c.entries[name] |
| 83 | if !ok { |
| 84 | return detectionEntry{}, false |
| 85 | } |
| 86 | if entry.DetectedAt.IsZero() || time.Since(entry.DetectedAt) > detectionTTL { |
| 87 | return entry, false |
| 88 | } |
| 89 | return entry, true |
| 90 | } |
| 91 | |
| 92 | // put stores a fresh detection result. |
| 93 | func (c *detectionCache) put(name string, installed bool, version string) { |
no outgoing calls