Class Cache<ApiType extends io.kubernetes.client.common.KubernetesObject>
java.lang.Object
io.kubernetes.client.informer.cache.Cache<ApiType>
public class Cache<ApiType extends io.kubernetes.client.common.KubernetesObject>
extends Object
implements Indexer<ApiType>
Cache is a java port of k/client-go's ThreadSafeStore. It basically saves and indexes all the
entries.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add objects.void
Add additional indexers to the cache.void
Add index func.By index list.void
Delete the object.Get object t.Gets get by key.Return the indexers registered with the cache.Get objects .Index keys list.list()
List all objects in the cache.listKeys()
List keys.void
Replace the content in the cache completely.void
resync()
Resync.void
setKeyFunc
(Function<ApiType, String> keyFunc) void
Update the object.void
updateIndices
(ApiType oldObj, ApiType newObj, String key) updateIndices modifies the objects location in the managed indexes, if this is an update, you must provide an oldObj.
-
Constructor Details
-
Cache
public Cache() -
Cache
public Cache(String indexName, Function<ApiType, List<String>> indexFunc, Function<ApiType, String> keyFunc) Constructor.- Parameters:
indexName
- the index name, an unique name representing the indexindexFunc
- the index func by which we map multiple object to an index for queryingkeyFunc
- the key func by which we map one object to an unique key for storing
-
-
Method Details
-
add
Add objects. -
update
Update the object. -
delete
Delete the object. -
replace
Replace the content in the cache completely. -
resync
public void resync()Resync. -
listKeys
List keys. -
get
Get object t. -
list
List all objects in the cache. -
getByKey
Gets get by key. -
index
Get objects . -
indexKeys
Index keys list. -
byIndex
By index list. -
getIndexers
Return the indexers registered with the cache.- Specified by:
getIndexers
in interfaceIndexer<ApiType extends io.kubernetes.client.common.KubernetesObject>
- Returns:
- registered indexers
-
addIndexers
Add additional indexers to the cache.- Specified by:
addIndexers
in interfaceIndexer<ApiType extends io.kubernetes.client.common.KubernetesObject>
- Parameters:
newIndexers
- indexers to add
-
updateIndices
updateIndices modifies the objects location in the managed indexes, if this is an update, you must provide an oldObj.Note: updateIndices must be called from a function that already has a lock on the cache.
- Parameters:
oldObj
- the old objnewObj
- the new objkey
- the key
-
addIndexFunc
Add index func.- Parameters:
indexName
- the index nameindexFunc
- the index func
-
getKeyFunc
-
setKeyFunc
-