Documentation
¶
Overview ¶
Package acceptcache stores the result of a CanAccept() call so the scheduler can reuse it on the next considerWork cycle without paying the (potentially expensive) cost of re-evaluating CanAccept. The entries expire after a configurable TTL to avoid acting on stale decisions.
Index ¶
- type Cache
- func (c *Cache) Add(ids []int64)
- func (c *Cache) Consume() []int64
- func (c *Cache) Forget(ids []int64)
- func (c *Cache) GetMatching(candidates []int64) (matched []int64, checked bool)
- func (c *Cache) Refresh()
- func (c *Cache) Store(candidates, accepted []int64)
- func (c *Cache) TakeMatching(candidates []int64) (matched []int64, hadFresh bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores accepted task IDs and the candidates checked by CanAccept. All methods are safe to call concurrently.
func (*Cache) Add ¶
Add appends accepted IDs, marks them checked, and refreshes the TTL baseline. Duplicate IDs are skipped.
func (*Cache) Consume ¶
Consume returns all cached accepted IDs, retaining their checked coverage. Expired evaluations are discarded and return nil.
func (*Cache) Forget ¶ added in v1.29.0
Forget removes acceptance and checked coverage without refreshing the TTL.
func (*Cache) GetMatching ¶ added in v1.29.0
GetMatching returns accepted candidates without consuming them. checked is true only when every candidate has a fresh evaluation; matched can still contain accepted IDs when some candidates have not been checked.
func (*Cache) Refresh ¶ added in v1.29.0
func (c *Cache) Refresh()
Refresh allows refused or consumed IDs to be checked again while retaining accepted IDs. It does not refresh the TTL.
func (*Cache) Store ¶ added in v1.29.0
Store replaces the cached evaluation, including an empty accepted result.
func (*Cache) TakeMatching ¶
TakeMatching removes and returns cached ids that appear in candidates. Unmatched cached ids are left in place for later considerWork calls.
hadFresh is false when the cache is empty or TTL-expired (caller should call CanAccept for the full candidate set). hadFresh is true when the cache held live entries — even if matched is empty. An empty match with hadFresh true is a cache miss for this candidate set, not a CanAccept refusal; the caller must call CanAccept rather than treating it as deny.