Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewImpersonationCache = runtimecache.NewImpersonationCache

Functions

func HashRegex added in v0.13.5

func HashRegex(expr runtime.ExpressionRegex) string

func ShouldInvalidate

func ShouldInvalidate(last *metav1.Time, now time.Time, interval time.Duration) bool

Types

type CELCache added in v0.13.11

type CELCache struct {
	// contains filtered or unexported fields
}

func NewCELCache added in v0.13.11

func NewCELCache() (*CELCache, error)

func (*CELCache) DeleteMany added in v0.13.11

func (c *CELCache) DeleteMany(expressions ...string) int

func (*CELCache) GetOrCompileBoolean added in v0.13.11

func (c *CELCache) GetOrCompileBoolean(
	expression string,
	mode environment.Type,
) (*celruntime.CompiledExpression, error)

func (*CELCache) GetOrCompileCondition added in v0.15.0

func (c *CELCache) GetOrCompileCondition(expression string, mode environment.Type) (*celruntime.CompiledExpression, error)

func (*CELCache) GetOrCompileQuantity added in v0.13.11

func (c *CELCache) GetOrCompileQuantity(
	expression string,
	mode environment.Type,
) (*celruntime.CompiledExpression, error)

func (*CELCache) GetOrCompileResourceCondition added in v0.15.0

func (c *CELCache) GetOrCompileResourceCondition(expression string, mode environment.Type) (*celruntime.CompiledExpression, error)

func (*CELCache) PruneConditions added in v0.15.0

func (c *CELCache) PruneConditions(retain map[string]struct{})

PruneConditions retires rule expressions without changing custom-quota entries.

func (*CELCache) Reset added in v0.15.0

func (c *CELCache) Reset()

Reset retires cached programs without changing programs already in use.

func (*CELCache) ResetQuotaExpressions added in v0.15.0

func (c *CELCache) ResetQuotaExpressions()

ResetQuotaExpressions retires quota programs while preserving admission conditions, the bounded resource-condition working set, and programs already in use.

func (*CELCache) Stats added in v0.13.11

func (c *CELCache) Stats() int

type CompiledRegex added in v0.13.5

type CompiledRegex struct {
	ID         string
	Expression string
	Negate     bool
	RE         *regexp.Regexp
}

func (*CompiledRegex) MatchString added in v0.13.5

func (r *CompiledRegex) MatchString(value string) bool

type CompiledRule

type CompiledRule struct {
	Match runtime.ExpressionMatch

	// RegexID is empty when Match.Expression is empty.
	RegexID string

	AllowedPolicy map[corev1.PullPolicy]struct{} // nil/empty => allow any
}

func (*CompiledRule) AllowsPullPolicy added in v0.13.5

func (r *CompiledRule) AllowsPullPolicy(pullPolicy corev1.PullPolicy) bool

type CompiledTarget

type CompiledTarget struct {
	capsulev1beta2.CustomQuotaStatusTarget

	CompiledPath       *jsonpath.CompiledJSONPath
	CompiledCEL        *celruntime.CompiledExpression
	CompiledSelectors  []selectors.CompiledSelectorWithFields
	CompiledConditions []*jsonpath.CompiledJSONPath
}

type CompiledTargetsCache

type CompiledTargetsCache[K comparable] struct {
	// contains filtered or unexported fields
}

func NewCompiledTargetsCache

func NewCompiledTargetsCache[K comparable]() *CompiledTargetsCache[K]

func (*CompiledTargetsCache[K]) Delete

func (c *CompiledTargetsCache[K]) Delete(key K) bool

func (*CompiledTargetsCache[K]) Get

func (c *CompiledTargetsCache[K]) Get(key K) ([]CompiledTarget, bool)

func (*CompiledTargetsCache[K]) GetOrBuild

func (c *CompiledTargetsCache[K]) GetOrBuild(key K, build func() ([]CompiledTarget, error)) ([]CompiledTarget, error)

func (*CompiledTargetsCache[K]) PruneActive

func (c *CompiledTargetsCache[K]) PruneActive(active map[K]struct{}) int

func (*CompiledTargetsCache[K]) Reset

func (c *CompiledTargetsCache[K]) Reset()

func (*CompiledTargetsCache[K]) Set

func (c *CompiledTargetsCache[K]) Set(key K, value []CompiledTarget)

func (*CompiledTargetsCache[K]) Stats

func (c *CompiledTargetsCache[K]) Stats() int

type DiscoveryNamespacedResourceCache

type DiscoveryNamespacedResourceCache struct {
	// contains filtered or unexported fields
}

func NewDiscoveryNamespacedResourceCache

func NewDiscoveryNamespacedResourceCache() DiscoveryNamespacedResourceCache

func NewDiscoveryNamespacedResourceCacheWithTTL

func NewDiscoveryNamespacedResourceCacheWithTTL(ttl time.Duration) DiscoveryNamespacedResourceCache

func (*DiscoveryNamespacedResourceCache) Get

func (*DiscoveryNamespacedResourceCache) Invalidate

func (c *DiscoveryNamespacedResourceCache) Invalidate()

type ImpersonationCache

type ImpersonationCache = runtimecache.ImpersonationCache

type JSONPathCache

type JSONPathCache struct {
	// contains filtered or unexported fields
}

func NewJSONPathCache

func NewJSONPathCache() *JSONPathCache

func (*JSONPathCache) Delete

func (c *JSONPathCache) Delete(path string) bool

func (*JSONPathCache) DeleteMany

func (c *JSONPathCache) DeleteMany(expressions ...string) int

func (*JSONPathCache) Get

func (*JSONPathCache) GetOrCompile

func (c *JSONPathCache) GetOrCompile(path string) (*jsonpath.CompiledJSONPath, error)

func (*JSONPathCache) PruneActive

func (c *JSONPathCache) PruneActive(active map[string]struct{}) int

func (*JSONPathCache) Reset

func (c *JSONPathCache) Reset()

func (*JSONPathCache) Stats

func (c *JSONPathCache) Stats() int

type Key

type Key = runtimecache.Key

type LabelSelectorCache added in v0.15.0

type LabelSelectorCache struct {
	// contains filtered or unexported fields
}

LabelSelectorCache stores immutable compiled selectors, never resource snapshots or match results. Content keys make changed/deleted/recreated PDBs independent of informer freshness. A bounded generation retires unused selectors without watching resources or retaining an unbounded history of dry-run requests.

func NewLabelSelectorCache added in v0.15.0

func NewLabelSelectorCache() *LabelSelectorCache

func (*LabelSelectorCache) GetOrCompile added in v0.15.0

func (c *LabelSelectorCache) GetOrCompile(selector *metav1.LabelSelector) (labels.Selector, error)

GetOrCompile returns a read-only selector. Callers must not modify it.

type PendingDeleteHint

type PendingDeleteHint struct {
	UID       types.UID
	CreatedAt time.Time
}

type QuantityCache

type QuantityCache[K comparable] struct {
	// contains filtered or unexported fields
}

func NewQuantityCache

func NewQuantityCache[K comparable]() *QuantityCache[K]

func (*QuantityCache[K]) AddPendingDelete

func (c *QuantityCache[K]) AddPendingDelete(key K, uid types.UID)

func (*QuantityCache[K]) Delete

func (c *QuantityCache[K]) Delete(key K) bool

func (*QuantityCache[K]) DeleteReservation

func (c *QuantityCache[K]) DeleteReservation(key K, reservationID string) bool

func (*QuantityCache[K]) Get

func (c *QuantityCache[K]) Get(key K) (QuantityEntry, bool)

func (*QuantityCache[K]) HasPendingDeletes

func (c *QuantityCache[K]) HasPendingDeletes(key K) bool

func (*QuantityCache[K]) Len

func (c *QuantityCache[K]) Len() int

func (*QuantityCache[K]) PendingDeletes

func (c *QuantityCache[K]) PendingDeletes(key K) []types.UID

func (*QuantityCache[K]) PurgeReservationsForKey

func (c *QuantityCache[K]) PurgeReservationsForKey(
	key K,
	shouldDelete func(Reservation) bool,
) int

PurgeReservationsForKey removes reservations for which shouldDelete returns true. Returns number of removed reservations.

func (*QuantityCache[K]) RemovePendingDelete

func (c *QuantityCache[K]) RemovePendingDelete(key K, uid types.UID) bool

func (*QuantityCache[K]) Snapshot

func (c *QuantityCache[K]) Snapshot() map[K]QuantityEntry

func (*QuantityCache[K]) UpsertReservation

func (c *QuantityCache[K]) UpsertReservation(
	key K,
	reservation Reservation,
	persistedUsed resource.Quantity,
	limit resource.Quantity,
) (allowed bool, effectiveUsed resource.Quantity, entry QuantityEntry)

UpsertReservation ensures a reservation is idempotent per (key, reservationID). It validates:

persistedUsed + sum(all reservations including this one) <= limit

type QuantityEntry

type QuantityEntry struct {
	Reserved       resource.Quantity
	Reservations   map[string]Reservation
	PendingDeletes []PendingDeleteHint
	CreatedAt      time.Time
	UpdatedAt      time.Time
	LastAccess     time.Time
}

type RegexCache added in v0.13.5

type RegexCache struct {
	// contains filtered or unexported fields
}

func NewRegexCache added in v0.13.5

func NewRegexCache() *RegexCache

func (*RegexCache) GetOrCompile added in v0.13.5

func (c *RegexCache) GetOrCompile(expr runtime.ExpressionRegex) (*CompiledRegex, bool, error)

func (*RegexCache) Has added in v0.13.5

func (c *RegexCache) Has(id string) bool

func (*RegexCache) MatchRegex added in v0.13.7

func (c *RegexCache) MatchRegex(expr runtime.ExpressionRegex, value string) (bool, error)

func (*RegexCache) Reset added in v0.13.5

func (c *RegexCache) Reset()

func (*RegexCache) Stats added in v0.13.5

func (c *RegexCache) Stats() int

type RegistryRuleSetCache

type RegistryRuleSetCache struct {
	// contains filtered or unexported fields
}

func NewRegistryRuleSetCache

func NewRegistryRuleSetCache(regexCache *RegexCache) *RegistryRuleSetCache

func (*RegistryRuleSetCache) GetOrBuild

func (c *RegistryRuleSetCache) GetOrBuild(specRules []rules.OCIRegistry) (rs *RuleSet, fromCache bool, err error)

func (*RegistryRuleSetCache) Has

func (c *RegistryRuleSetCache) Has(id string) bool

func (*RegistryRuleSetCache) HashRules

func (c *RegistryRuleSetCache) HashRules(specRules []rules.OCIRegistry) string

func (*RegistryRuleSetCache) Match added in v0.13.5

func (c *RegistryRuleSetCache) Match(
	specRules []rules.OCIRegistry,
	reference string,
	pullPolicy corev1.PullPolicy,
) (*CompiledRule, error)

Match matches reference, expression and pullPolicy. Admission evaluation should usually use MatchReference instead.

func (*RegistryRuleSetCache) MatchReference added in v0.13.5

func (c *RegistryRuleSetCache) MatchReference(
	rs *RuleSet,
	reference string,
) (*CompiledRule, error)

MatchReference matches reference only. It intentionally does not check pullPolicy.

func (*RegistryRuleSetCache) MatchRuleSet added in v0.13.5

func (c *RegistryRuleSetCache) MatchRuleSet(
	rs *RuleSet,
	reference string,
	pullPolicy corev1.PullPolicy,
) (*CompiledRule, error)

func (*RegistryRuleSetCache) PruneActive

func (c *RegistryRuleSetCache) PruneActive(activeIDs map[string]struct{}) int

func (*RegistryRuleSetCache) Reset

func (c *RegistryRuleSetCache) Reset()

func (*RegistryRuleSetCache) Stats

func (c *RegistryRuleSetCache) Stats() int

type Reservation

type Reservation struct {
	ID        string
	Usage     resource.Quantity
	UID       types.UID
	Group     string
	Version   string
	Kind      string
	Namespace string
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type RuleSet

type RuleSet struct {
	ID       string
	Compiled []CompiledRule
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL