Package uk.gov.gchq.gaffer.cache.impl
Class HazelcastCache<K,V>
- java.lang.Object
-
- uk.gov.gchq.gaffer.cache.impl.HazelcastCache<K,V>
-
- Type Parameters:
K- The object type that acts as the key for the IMapV- The value that is stored in the IMap
- All Implemented Interfaces:
ICache<K,V>
public class HazelcastCache<K,V> extends Object implements ICache<K,V>
Implementation of theICacheinterface, using a HazelcastIMapas the cache data store.
-
-
Constructor Summary
Constructors Constructor Description HazelcastCache(com.hazelcast.map.IMap<K,V> distributedMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Remove all entries from the cache.Vget(K key)Retrieve the value associated with the given key.Set<K>getAllKeys()Get all keys present in the cache.Collection<V>getAllValues()Get all values present in the cache.voidput(K key, V value)Add a new key-value pair to the cache.voidremove(K key)Remove the entry associated with the specified key.intsize()Get the size of the cache.
-
-
-
Method Detail
-
get
public V get(K key)
Description copied from interface:ICacheRetrieve the value associated with the given key.
-
put
public void put(K key, V value) throws CacheOperationException
Description copied from interface:ICacheAdd a new key-value pair to the cache.- Specified by:
putin interfaceICache<K,V>- Parameters:
key- the key to addvalue- the value to add- Throws:
CacheOperationException- if there is an error adding the new key-value pair to the cache
-
remove
public void remove(K key)
Description copied from interface:ICacheRemove the entry associated with the specified key.
-
getAllValues
public Collection<V> getAllValues()
Description copied from interface:ICacheGet all values present in the cache.- Specified by:
getAllValuesin interfaceICache<K,V>- Returns:
- a
Iterablecontaining all of the cache values
-
getAllKeys
public Set<K> getAllKeys()
Description copied from interface:ICacheGet all keys present in the cache.- Specified by:
getAllKeysin interfaceICache<K,V>- Returns:
- a
Iterablecontaining all of the cache keys
-
size
public int size()
Description copied from interface:ICacheGet the size of the cache.
-
clear
public void clear() throws CacheOperationExceptionDescription copied from interface:ICacheRemove all entries from the cache.- Specified by:
clearin interfaceICache<K,V>- Throws:
CacheOperationException- if there was an error clearing the cache
-
-