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

cache

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashRegex added in v0.13.5

func HashRegex(expr api.RegExpression) string

func ShouldInvalidate

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

Types

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 {
	Expression api.RegExpression
	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
	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 struct {
	// contains filtered or unexported fields
}

func NewImpersonationCache

func NewImpersonationCache() *ImpersonationCache

func (*ImpersonationCache) Get

func (c *ImpersonationCache) Get(ns, name string) (client.Client, bool)

Get returns a cached client if present.

func (*ImpersonationCache) Invalidate

func (c *ImpersonationCache) Invalidate(namespace, name string)

Invalidate removes one entry.

func (*ImpersonationCache) LoadOrCreate

LoadOrCreate returns a cached impersonated client for the given service account, creating and caching it if missing.

func (*ImpersonationCache) Reset

func (c *ImpersonationCache) Reset()

Clear drops all cached clients.

func (*ImpersonationCache) Set

func (c *ImpersonationCache) Set(namespace, name string, cl client.Client)

Set stores a client explicitly (rarely needed).

func (*ImpersonationCache) Stats

func (c *ImpersonationCache) Stats() (entries int)

Stats helps you log cache state.

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 struct {
	Namespace string
	Name      string
}

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 api.RegExpression) (*CompiledRegex, bool, error)

func (*RegexCache) Has added in v0.13.5

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

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, regex 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 and regex 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