sweepMisses periodically drops expired negative-cache entries so missCache cannot grow without bound as distinct bogus shas arrive. Intended to run in a background goroutine; the interval is half the TTL (Nyquist-ish). Stops only when the process exits (no graceful-shutdown context exists).
(ctx context.Context)
| 963 | // a background goroutine; the interval is half the TTL (Nyquist-ish). Stops |
| 964 | // only when the process exits (no graceful-shutdown context exists). |
| 965 | func (h *commitServiceHandler) sweepMisses(ctx context.Context) { |
| 966 | interval := h.probeNegativeTTL / 2 |
| 967 | if interval <= 0 { |
| 968 | return |
| 969 | } |
| 970 | t := time.NewTicker(interval) |
| 971 | defer t.Stop() |
| 972 | for { |
| 973 | select { |
| 974 | case <-ctx.Done(): |
| 975 | return |
| 976 | case now := <-t.C: |
| 977 | cutoff := now |
| 978 | h.commitMu.Lock() |
| 979 | for sha, t := range h.missCache { |
| 980 | if cutoff.Sub(t) >= h.probeNegativeTTL { |
| 981 | delete(h.missCache, sha) |
| 982 | } |
| 983 | } |
| 984 | h.commitMu.Unlock() |
| 985 | } |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | // probeCommitID resolves a Download commit_id (= git sha) that was neither |
| 990 | // minted in-session nor recoverable by the single-module fallback, by asking |
no test coverage detected