Documentation ¶
Index ¶
- Constants
- Variables
- func AddInformerTransformFuncToCacheOption(opts *cache.Options)
- func BuildCache(ctx context.Context, scheme *runtime.Scheme, shardingObjects ...client.Object) cache.NewCacheFunc
- func NewResourcesToDisableCache() []client.Object
- type DefinitionCache
- type ObjectCache
- func (in *ObjectCache[T]) Add(hash string, obj *T, ref string) *T
- func (in *ObjectCache[T]) DeleteRef(hash string, ref string)
- func (in *ObjectCache[T]) Get(hash string) *T
- func (in *ObjectCache[T]) Prune(outdated time.Duration) int
- func (in *ObjectCache[T]) Remap(m map[string]*T, ref string)
- func (in *ObjectCache[T]) Size() int
- func (in *ObjectCache[T]) Unmap(m map[string]*T, ref string)
- type ObjectCacheEntry
Constants ¶
const AppIndex = "app"
AppIndex identify the index for resourcetracker to accelerate cache retrieval
Variables ¶
var ( // ApplicationRevisionDefinitionCachePruneDuration the prune duration for application revision definition cache ApplicationRevisionDefinitionCachePruneDuration = time.Hour )
var DefaultDefinitionCache = singleton.NewSingleton(NewDefinitionCache)
DefaultDefinitionCache the default definition cache
var ( // OptimizeListOp optimize ResourceTracker & ApplicationRevision list op by adding index // used in controller optimization (informer index). Client side should not use it. OptimizeListOp = false )
Functions ¶
func AddInformerTransformFuncToCacheOption ¶
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 BuildCache ¶
func BuildCache(ctx context.Context, scheme *runtime.Scheme, shardingObjects ...client.Object) cache.NewCacheFunc
BuildCache if optimize-list-op enabled, ResourceTracker and ApplicationRevision will be cached by application namespace & name
func NewResourcesToDisableCache ¶
NewResourcesToDisableCache get ClientDisableCacheFor for building controller
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) 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]) 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