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 theICache
interface, using a HazelcastIMap
as 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 void
clear()
Remove all entries from the cache.V
get(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.void
put(K key, V value)
Add a new key-value pair to the cache.void
remove(K key)
Remove the entry associated with the specified key.int
size()
Get the size of the cache.
-
-
-
Method Detail
-
get
public V get(K key)
Description copied from interface:ICache
Retrieve the value associated with the given key.
-
put
public void put(K key, V value) throws CacheOperationException
Description copied from interface:ICache
Add a new key-value pair to the cache.- Specified by:
put
in 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:ICache
Remove the entry associated with the specified key.
-
getAllValues
public Collection<V> getAllValues()
Description copied from interface:ICache
Get all values present in the cache.- Specified by:
getAllValues
in interfaceICache<K,V>
- Returns:
- a
Iterable
containing all of the cache values
-
getAllKeys
public Set<K> getAllKeys()
Description copied from interface:ICache
Get all keys present in the cache.- Specified by:
getAllKeys
in interfaceICache<K,V>
- Returns:
- a
Iterable
containing all of the cache keys
-
size
public int size()
Description copied from interface:ICache
Get the size of the cache.
-
clear
public void clear() throws CacheOperationException
Description copied from interface:ICache
Remove all entries from the cache.- Specified by:
clear
in interfaceICache<K,V>
- Throws:
CacheOperationException
- if there was an error clearing the cache
-
-