Interface Store<T>
- Type Parameters:
T- resource
- All Known Subinterfaces:
Indexer<T>
public interface Store<T>
Store is a generic object storage interface. Reflector knows how to watch a server
and update a store. A generic store is provided, which allows Reflector to be used
as a local caching system, and an Least Recently Used store, which allows Reflector
to work like a queue of items yet to be processed.
It makes no assumptions about the stored object identity; it is the responsibility
of a Store implementation to provide a mechanism to correctly key objects and to
define the contract for obtaining objects by some arbitrary key type.
This is ported from official go client: https://github.com/kubernetes/client-go/blob/master/tools/cache/store.go
-
Method Summary
Modifier and Type Method Description voidadd(T obj)Inserts an item into the storevoiddelete(T obj)Removes an item from the storeObjectget(T object)Returns the requested item.TgetByKey(String key)Returns the request item with specific key.voidisPopulated(boolean isPopulated)Updates the status of cache in case of any API error from Kubernetes serverList<T>list()Returns a list of all the items.List<String>listKeys()returns a list of all keys of the object currently in the store.voidreplace(List<T> list, String resourceVersion)Deletes the contents of the store, using instead the given list.voidresync()Sends a resync event for each item.voidupdate(T obj)Sets an item in the store to its updated state.
-
Method Details
-
add
Inserts an item into the store- Parameters:
obj- object
-
update
Sets an item in the store to its updated state.- Parameters:
obj- object
-
delete
Removes an item from the store- Parameters:
obj- object
-
list
Returns a list of all the items.- Returns:
- list of all items
-
listKeys
returns a list of all keys of the object currently in the store.- Returns:
- list of all keys
-
get
Returns the requested item.- Parameters:
object- object- Returns:
- requested item if exists.
-
getByKey
Returns the request item with specific key.- Parameters:
key- specific key- Returns:
- the requested item
-
replace
Deletes the contents of the store, using instead the given list. Store takes ownership of the list, you should not reference it after calling this function- Parameters:
list- list of objectsresourceVersion- resource version
-
resync
void resync()Sends a resync event for each item. -
isPopulated
void isPopulated(boolean isPopulated)Updates the status of cache in case of any API error from Kubernetes server- Parameters:
isPopulated- boolean value indicating whether cache is populated or not
-