Class HazelcastCache<K,​V>

  • Type Parameters:
    K - The object type that acts as the key for the IMap
    V - 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 the ICache interface, using a Hazelcast IMap as the cache data store.
    • Constructor Detail

      • HazelcastCache

        public HazelcastCache​(com.hazelcast.map.IMap<K,​V> distributedMap)
    • Method Detail

      • get

        public V get​(K key)
        Description copied from interface: ICache
        Retrieve the value associated with the given key.
        Specified by:
        get in interface ICache<K,​V>
        Parameters:
        key - the key to lookup in the cache
        Returns:
        the value associated with the 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 interface ICache<K,​V>
        Parameters:
        key - the key to add
        value - 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.
        Specified by:
        remove in interface ICache<K,​V>
        Parameters:
        key - the key of the entry to remove
      • getAllValues

        public Collection<V> getAllValues()
        Description copied from interface: ICache
        Get all values present in the cache.
        Specified by:
        getAllValues in interface ICache<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 interface ICache<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.
        Specified by:
        size in interface ICache<K,​V>
        Returns:
        the number of entries in the caches