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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(T obj)
Inserts an item into the storevoid
delete(T obj)
Removes an item from the storeObject
get(T object)
Returns the requested item.T
getByKey(String key)
Returns the request item with specific key.void
isPopulated(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.void
replace(List<T> list, String resourceVersion)
Deletes the contents of the store, using instead the given list.void
resync()
Sends a resync event for each item.void
update(T obj)
Sets an item in the store to its updated state.
-
-
-
Method Detail
-
add
void add(T obj)
Inserts an item into the store- Parameters:
obj
- object
-
update
void update(T obj)
Sets an item in the store to its updated state.- Parameters:
obj
- object
-
delete
void delete(T obj)
Removes an item from the store- Parameters:
obj
- object
-
listKeys
List<String> listKeys()
returns a list of all keys of the object currently in the store.- Returns:
- list of all keys
-
get
Object get(T object)
Returns the requested item.- Parameters:
object
- object- Returns:
- requested item if exists.
-
getByKey
T getByKey(String key)
Returns the request item with specific key.- Parameters:
key
- specific key- Returns:
- the requested item
-
replace
void replace(List<T> list, String resourceVersion)
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
-
-