cache

package
v1.12.0-alpha.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UsageComponent = "component"
	UsageTrait     = "trait"
)

The kinds a quota can count. Only these two: a policy, workflow step or source is not a thing a namespace accumulates.

View Source
const AppIndex = "app"

AppIndex identify the index for resourcetracker to accelerate cache retrieval

View Source
const DefinitionUsageIndex = "definitionUsage"

DefinitionUsageIndex indexes Applications by the definitions they use, so a quota can be counted without walking the namespace. Values are kind-prefixed, since a component type and a trait type may share a name and carry separate quotas. An Application appears under each key it uses, pin stripped, so webservice@v1 counts against webservice.

Variables

View Source
var (
	// OptimizeListOp optimize ResourceTracker & ApplicationRevision list op by adding index
	// used in controller optimization (informer index). Client side should not use it.
	OptimizeListOp = false

	// DefinitionUsageIndexed reports whether DefinitionUsageIndex was registered.
	// Querying an index that was not fails the request, so callers read this rather
	// than work the condition out again.
	DefinitionUsageIndexed = false
)
View Source
var (
	// ApplicationRevisionDefinitionCachePruneDuration the prune duration for application revision definition cache
	ApplicationRevisionDefinitionCachePruneDuration = time.Hour
)
View Source
var DefaultDefinitionCache = singleton.NewSingleton(NewDefinitionCache)

DefaultDefinitionCache the default definition cache

Functions

func AddInformerTransformFuncToCacheOption

func AddInformerTransformFuncToCacheOption(opts *cache.Options)

AddInformerTransformFuncToCacheOption add informer transform func to cache option This will filter out the unnecessary fields for cached objects and use definition cache to reduce the duplicated storage of same definitions

func BaseTypeName

func BaseTypeName(componentType string) string

BaseTypeName strips a version pin: webservice@v1 names the definition webservice.

func BuildCache

func BuildCache(ctx context.Context, opts cache.Options, shardingObjects ...client.Object) cache.NewCacheFunc

BuildCache if optimize-list-op enabled, ResourceTracker and ApplicationRevision will be cached by application namespace & name

func DefinitionUsageOf

func DefinitionUsageOf(app *v1beta1.Application) []string

DefinitionUsageOf lists the distinct definitions an Application uses, as kind prefixed keys. It backs DefinitionUsageIndex.

func NewResourcesToDisableCache

func NewResourcesToDisableCache() []client.Object

NewResourcesToDisableCache get ClientDisableCacheFor for building controller

func UsageKey

func UsageKey(kind, definitionType string) string

UsageKey is the index value for one definition of one kind.

Types

type DefinitionCache

type DefinitionCache struct {
	ComponentDefinitionCache    *ObjectCache[v1beta1.ComponentDefinition]
	TraitDefinitionCache        *ObjectCache[v1beta1.TraitDefinition]
	WorkflowStepDefinitionCache *ObjectCache[v1beta1.WorkflowStepDefinition]
}

DefinitionCache cache for definitions

func NewDefinitionCache

func NewDefinitionCache() *DefinitionCache

NewDefinitionCache create DefinitionCache

func (*DefinitionCache) RemapRevision

func (in *DefinitionCache) RemapRevision(rev *v1beta1.ApplicationRevision)

RemapRevision remap all definitions in the given revision

func (*DefinitionCache) Start

func (in *DefinitionCache) Start(ctx context.Context, store cache.Cache, duration time.Duration)

Start clear cache every duration

func (*DefinitionCache) UnmapRevision

func (in *DefinitionCache) UnmapRevision(rev *v1beta1.ApplicationRevision)

UnmapRevision unmap definitions from the provided revision by the given ref

type ObjectCache

type ObjectCache[T any] struct {
	// contains filtered or unexported fields
}

ObjectCache cache for objects

func NewObjectCache

func NewObjectCache[T any]() *ObjectCache[T]

NewObjectCache create an object cache

func (*ObjectCache[T]) Add

func (in *ObjectCache[T]) Add(hash string, obj *T, ref string) *T

Add insert cache entry with ref, return the ptr of the entry

func (*ObjectCache[T]) DeleteRef

func (in *ObjectCache[T]) DeleteRef(hash string, ref string)

DeleteRef delete ref for an obj

func (*ObjectCache[T]) Get

func (in *ObjectCache[T]) Get(hash string) *T

Get retrieve the cache entry

func (*ObjectCache[T]) Prune

func (in *ObjectCache[T]) Prune(outdated time.Duration) int

Prune remove outdated cache, return the pruned count

func (*ObjectCache[T]) Remap

func (in *ObjectCache[T]) Remap(m map[string]*T, ref string)

Remap relocate the object ptr with given ref

func (*ObjectCache[T]) Size

func (in *ObjectCache[T]) Size() int

Size get the size of the cache

func (*ObjectCache[T]) Unmap

func (in *ObjectCache[T]) Unmap(m map[string]*T, ref string)

Unmap drop all the hash object from the map

type ObjectCacheEntry

type ObjectCacheEntry[T any] struct {
	// contains filtered or unexported fields
}

ObjectCacheEntry entry for object cache

Jump to

Keyboard shortcuts

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