Core Cacheable Object
Overview
Know the information from the name of CacheableObject
. It could store the Object instance. In the 1.18 version of Kubernetes, cachingObject
is the only implementation of this interface - CacheableObject
. Its relation as this picture.
Combined with CacheableObject
definitions, it will be found that when the CacheableObject
is stored in Object, Identifier is specified, whether does it mean to save(cache) multiple Object?
The GetObject()
method is indeed returned to an Object instance, although the container class structure of Slice, Map cannot be eliminated to implement the possibility of Object interface, it is also a problem that needs to be deeply understood and resolved.
Let us continue and start by trying to solve these two questions and see what can have any gains.
cachingObject
Overview
Each cachingObject
actually stores an Object, which is the metaRuntimeInterface
instance. According to different Identifiers, this object is encoded into different formats and is cached in the map.
Implementation
Definition
metaRuntimeInterface
simultaneously implemented runtime.Object
interface and metav1.Object
interface.
metav1.Object
interface as this defined is using to describe Kuberentes core Object.
Creation
From the new method, we can see that a cachingObject
stores an instance, and when it stores an instance, it does not store the original object, but a deep copy
GetObject method Gets a deep copy of the metaRuntimeInterface instance.
Implementation for runtime.Object
CachingObject itself also implement the runtime.Object
interface, implemented as follows. It is important to note that in the DeepCopyObject()
method, a new SerializationCache is created, and the old content is not copied.
Implementation For CacheableObject
The focus is to replace the atomic.Value
, the operation as shown below.
Last updated