java.lang.Object
io.fabric8.kubernetes.client.informers.cache.Cache<T>
Type Parameters:
T - type for cache object
All Implemented Interfaces:
Indexer<T>, Store<T>

public class Cache<T>
extends Object
implements Indexer<T>
It basically saves and indexes all the entries.
  • Field Details

  • Constructor Details

  • Method Details

    • add

      public void add​(T obj)
      Add objects
      Specified by:
      add in interface Store<T>
      Parameters:
      obj - object
    • getIndexers

      public Map<String,​Function<T,​List<String>>> getIndexers()
      Returns the indexers registered with the cache.
      Specified by:
      getIndexers in interface Indexer<T>
      Returns:
      registered indexers
    • addIndexers

      public void addIndexers​(Map<String,​Function<T,​List<String>>> indexersNew)
      Description copied from interface: Indexer
      Add additional indexers to the store.
      Specified by:
      addIndexers in interface Indexer<T>
      Parameters:
      indexersNew - indexers to add
    • update

      public void update​(T obj)
      Update the object.
      Specified by:
      update in interface Store<T>
      Parameters:
      obj - the object
    • delete

      public void delete​(T obj)
      Delete the object.
      Specified by:
      delete in interface Store<T>
      Parameters:
      obj - object
    • replace

      public void replace​(List<T> list, String resourceVersion)
      Replace the content in the cache completely.
      Specified by:
      replace in interface Store<T>
      Parameters:
      list - list of objects
      resourceVersion - resource version
    • resync

      public void resync()
      Resync
      Specified by:
      resync in interface Store<T>
    • listKeys

      public List<String> listKeys()
      List keys
      Specified by:
      listKeys in interface Store<T>
      Returns:
      the list of keys
    • get

      public T get​(T obj)
      Get object
      Specified by:
      get in interface Store<T>
      Parameters:
      obj - the object
      Returns:
      the object
    • list

      public List<T> list()
      List all objects in the cache.
      Specified by:
      list in interface Store<T>
      Returns:
      the list
    • getByKey

      public T getByKey​(String key)
      Gets get by key.
      Specified by:
      getByKey in interface Store<T>
      Parameters:
      key - specific key
      Returns:
      the get by key
    • index

      public List<T> index​(String indexName, Object obj)
      Get objects
      Specified by:
      index in interface Indexer<T>
      Parameters:
      indexName - specific indexing function
      obj - object
      Returns:
      the list
    • indexKeys

      public List<String> indexKeys​(String indexName, String indexKey)
      Index keys list
      Specified by:
      indexKeys in interface Indexer<T>
      Parameters:
      indexName - specific indexing function
      indexKey - specific index key
      Returns:
      the list
    • byIndex

      public List<T> byIndex​(String indexName, String indexKey)
      By index list
      Specified by:
      byIndex in interface Indexer<T>
      Parameters:
      indexName - specific indexing function
      indexKey - specific index key
      Returns:
      the list
    • isPopulated

      public void isPopulated​(boolean isPopulated)
      Description copied from interface: Store
      Updates the status of cache in case of any API error from Kubernetes server
      Specified by:
      isPopulated in interface Store<T>
      Parameters:
      isPopulated - boolean value indicating whether cache is populated or not
    • updateIndices

      public void updateIndices​(T oldObj, T newObj, String key)
      UpdateIndices modifies the objects location in the managed indexes, if there is an update, you must provide an oldObj
      Parameters:
      oldObj - old object
      newObj - new object
      key - the key
    • addIndexFunc

      public void addIndexFunc​(String indexName, Function<T,​List<String>> indexFunc)
      Add index func.
      Parameters:
      indexName - the index name
      indexFunc - the index func
    • deletionHandlingMetaNamespaceKeyFunc

      public static <T> String deletionHandlingMetaNamespaceKeyFunc​(T object)
      Checks for DeletedFinalStateUnknown objects before calling metaNamespaceKeyFunc
      Type Parameters:
      T - object type
      Parameters:
      object - the specific object
      Returns:
      the key
    • metaNamespaceKeyFunc

      public static String metaNamespaceKeyFunc​(Object obj)
      It's is a convenient default KeyFunc which know show to make keys for API objects which implement HasMetadata interface. The key uses the format namespace/name unless namespace is empty, then it's just name
      Parameters:
      obj - specific object
      Returns:
      the key
    • metaNamespaceIndexFunc

      public static List<String> metaNamespaceIndexFunc​(Object obj)
      It is a default index function that indexes based on an object's namespace
      Parameters:
      obj - the specific object
      Returns:
      the indexed value