K
- the type of key for this QueryCache
V
- the type of value for this QueryCache
public interface QueryCache<K,V>
IMap
. It can be also thought
of as an always up to date view or snapshot of the IMap
.
Typically, QueryCache
is used for performance reasons.
This QueryCache
can be configured via QueryCacheConfig
.
It can be reached like this:
IMap map = hzInstance.getMap("mapName");
Predicate predicate = TruePredicate.INSTANCE;
QueryCache cache = map.getQueryCache(cacheId, predicate, includeValue);
This cache is evictable. The eviction can be configured with QueryCacheConfig.setEvictionConfig(com.hazelcast.config.EvictionConfig)
.
Events caused by IMap
eviction are not reflected to this cache.
But the events published after an explicit call to IMap.evict(K)
are reflected to this cache.
GOTCHAS
QueryCache
implementation relies on the eventing system, if
a listener is attached to this QueryCache
it may receive same
event more than once in case of a system failure. Check out tryRecover()
QueryCache
is reflected to underlying IMap
and that write operation will eventually be reflected to this
QueryCache
after receiving the event of that operation.
addEntryListener
for more details.
IMap
implementation, one should take care of
them before using this QueryCache
. Please check gotchas section
in IMap
class for them.
QueryCacheConfig
Modifier and Type | Method and Description |
---|---|
UUID |
addEntryListener(MapListener listener,
boolean includeValue) |
UUID |
addEntryListener(MapListener listener,
K key,
boolean includeValue) |
UUID |
addEntryListener(MapListener listener,
Predicate<K,V> predicate,
boolean includeValue) |
UUID |
addEntryListener(MapListener listener,
Predicate<K,V> predicate,
K key,
boolean includeValue) |
void |
addIndex(IndexConfig config) |
default void |
addIndex(IndexType type,
String... attributes) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
void |
destroy()
Destroys this cache.
|
Set<Map.Entry<K,V>> |
entrySet() |
Set<Map.Entry<K,V>> |
entrySet(Predicate<K,V> predicate) |
V |
get(Object key) |
Map<K,V> |
getAll(Set<K> keys) |
String |
getName()
Returns the name of this
QueryCache . |
boolean |
isEmpty() |
Set<K> |
keySet() |
Set<K> |
keySet(Predicate<K,V> predicate) |
boolean |
removeEntryListener(UUID id) |
int |
size() |
boolean |
tryRecover()
This method can be used to recover from a possible event loss situation.
|
Collection<V> |
values() |
Collection<V> |
values(Predicate<K,V> predicate) |
V get(Object key)
IMap.get(Object)
boolean containsKey(Object key)
IMap.containsKey(Object)
boolean containsValue(Object value)
IMap.containsValue(Object)
boolean isEmpty()
Map.isEmpty()
int size()
Map.size()
default void addIndex(IndexType type, String... attributes)
IMap.addIndex(IndexType, String...)
void addIndex(IndexConfig config)
IMap.addIndex(IndexConfig)
Set<K> keySet()
IMap.keySet()
Collection<V> values()
IMap.values()
Set<Map.Entry<K,V>> entrySet()
IMap.entrySet()
Collection<V> values(Predicate<K,V> predicate)
IMap.values(Predicate)
UUID addEntryListener(MapListener listener, boolean includeValue)
UUID addEntryListener(MapListener listener, K key, boolean includeValue)
UUID addEntryListener(MapListener listener, Predicate<K,V> predicate, boolean includeValue)
UUID addEntryListener(MapListener listener, Predicate<K,V> predicate, K key, boolean includeValue)
boolean removeEntryListener(UUID id)
IMap.removeEntryListener(UUID)
String getName()
QueryCache
. The returned value will never be null.QueryCache
.boolean tryRecover()
EventLostListener
This method tries to make consistent the data in this QueryCache
with the data in the underlying IMap
by replaying the events after last consistently received ones. As a result of this replaying logic, same event may
appear more than once to the QueryCache
listeners.
This method returns false
if the event is not in the buffer of event publisher side. That means recovery is not
possible.
true
if the QueryCache
content will be eventually consistent, otherwise false
.QueryCacheConfig.bufferSize
void destroy()
Copyright © 2024 Hazelcast, Inc.. All rights reserved.