com.hazelcast.map
Interface QueryCache<K,V>

Type Parameters:
K - the type of key for this QueryCache
V - the type of value for this QueryCache

@Beta
public interface QueryCache<K,V>

A concurrent, queryable data structure which is used to cache results of a continuous query executed on an IMap. It can be also think of 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(cacheName, predicate, includeValue);

 
 

This cache is evictable. The eviction can be configured with 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

Since:
3.5
See Also:
QueryCacheConfig

Method Summary
 String addEntryListener(MapListener listener, boolean includeValue)
           
 String addEntryListener(MapListener listener, K key, boolean includeValue)
           
 String addEntryListener(MapListener listener, Predicate<K,V> predicate, boolean includeValue)
           
 String addEntryListener(MapListener listener, Predicate<K,V> predicate, K key, boolean includeValue)
           
 void addIndex(String attribute, boolean ordered)
           
 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 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 predicate)
           
 boolean removeEntryListener(String 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 predicate)
           
 

Method Detail

get

V get(Object key)
See Also:
IMap.get(Object)

containsKey

boolean containsKey(Object key)
See Also:
IMap.containsKey(Object)

containsValue

boolean containsValue(Object value)
See Also:
IMap.containsValue(Object)

isEmpty

boolean isEmpty()
See Also:
Map.isEmpty()

size

int size()
See Also:
Map.size()

addIndex

void addIndex(String attribute,
              boolean ordered)
See Also:
IMap.addIndex(String, boolean)

getAll

Map<K,V> getAll(Set<K> keys)
See Also:
IMap.getAll(Set)

keySet

Set<K> keySet()
See Also:
IMap.keySet()

keySet

Set<K> keySet(Predicate predicate)
See Also:
IMap.keySet(Predicate)

entrySet

Set<Map.Entry<K,V>> entrySet()
See Also:
IMap.entrySet()

entrySet

Set<Map.Entry<K,V>> entrySet(Predicate predicate)
See Also:
IMap.entrySet(Predicate)

values

Collection<V> values()
See Also:
IMap.values()

values

Collection<V> values(Predicate predicate)
See Also:
IMap.values(Predicate)

addEntryListener

String addEntryListener(MapListener listener,
                        boolean includeValue)
See Also:
IMap.addEntryListener(MapListener, boolean)

addEntryListener

String addEntryListener(MapListener listener,
                        K key,
                        boolean includeValue)
See Also:
IMap.addEntryListener(MapListener, Object, boolean)

addEntryListener

String addEntryListener(MapListener listener,
                        Predicate<K,V> predicate,
                        boolean includeValue)
See Also:
IMap.addEntryListener(MapListener, Predicate, boolean)

addEntryListener

String addEntryListener(MapListener listener,
                        Predicate<K,V> predicate,
                        K key,
                        boolean includeValue)
See Also:
IMap.addEntryListener(MapListener, Predicate, Object, boolean)

removeEntryListener

boolean removeEntryListener(String id)
See Also:
IMap.removeEntryListener(String)

getName

String getName()
Returns the name of this QueryCache. The returned value will never be null.

Returns:
the name of this QueryCache.

tryRecover

boolean tryRecover()
This method can be used to recover from a possible event loss situation.

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.

Returns:
true if the QueryCache content will be eventually consistent, otherwise false.
See Also:
QueryCacheConfig.bufferSize

destroy

void destroy()
Destroys this cache. Clears and releases all local and remote resources created for this cache.



Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.