MCPcopy
hub / github.com/kubernetes/client-go / newerObject

Method newerObject

tools/cache/mutation_cache.go:178–192  ·  view source on GitHub ↗

newerObject checks the mutation cache for a newer object and returns one if found. If the mutated object is older than the backing object, it is removed from the Must be called while the lock is held.

(key string, backing runtime.Object)

Source from the content-addressed store, hash-verified

176// mutated object is older than the backing object, it is removed from the Must be
177// called while the lock is held.
178func (c *mutationCache) newerObject(key string, backing runtime.Object) runtime.Object {
179 mutatedObj, exists := c.mutationCache.Get(key)
180 if !exists {
181 return backing
182 }
183 mutatedObjRuntime, ok := mutatedObj.(runtime.Object)
184 if !ok {
185 return backing
186 }
187 if c.comparator.CompareResourceVersion(backing, mutatedObjRuntime) >= 0 {
188 c.mutationCache.Remove(key)
189 return backing
190 }
191 return mutatedObjRuntime
192}
193
194// Mutation adds a change to the cache that can be returned in GetByKey if it is newer than the backingCache
195// copy. If you call Mutation twice with the same object on different threads, one will win, but its not defined

Callers 2

GetByKeyMethod · 0.95
ByIndexMethod · 0.95

Calls 2

GetMethod · 0.65

Tested by

no test coverage detected