be.ehealth.technicalconnector.cache.impl
Class HashMapCache<K,V>

java.lang.Object
  extended by be.ehealth.technicalconnector.cache.impl.HashMapCache<K,V>
All Implemented Interfaces:
Cache<K,V>

public class HashMapCache<K,V>
extends Object
implements Cache<K,V>

Implementation of Cache based on a HashMap implementation. Warning Not safe to use in a multi threaded environment.


Constructor Summary
HashMapCache()
           
 
Method Summary
 void clear()
          Clear the cache.
 boolean containsKey(K key)
          Returns true, if there is a mapping for the specified key.
 V get(K key)
          Returns a value associated by the given key, that contains a non expired value.
 String getName()
          A configured or generated name of this cache instance.
 void put(K key, V value)
          Updates an existing cache entry for the specified key, so it associates the given value, or, insert a new cache entry for this key and value.
 void putAll(Map<K,V> map)
           
 void remove(K key)
          Removes the mapping for a key from the cache if it is present.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapCache

public HashMapCache()
Method Detail

getName

public String getName()
Description copied from interface: Cache
A configured or generated name of this cache instance.

Specified by:
getName in interface Cache<K,V>
Returns:
name of this cache or null for anonymous caches.

get

public V get(K key)
Description copied from interface: Cache
Returns a value associated by the given key, that contains a non expired value. If no value is present or it is expired the cache loader is invoked, if configured, or null is returned.

Specified by:
get in interface Cache<K,V>
Parameters:
key - key with which the specified value is associated
Returns:
the value associated with the specified key, or null if there was no mapping for the key.

containsKey

public boolean containsKey(K key)
Description copied from interface: Cache
Returns true, if there is a mapping for the specified key.

Specified by:
containsKey in interface Cache<K,V>
Parameters:
key - key which association should be checked
Returns:
true, if this cache contains a mapping for the specified key

put

public void put(K key,
                V value)
Description copied from interface: Cache
Updates an existing cache entry for the specified key, so it associates the given value, or, insert a new cache entry for this key and value.

Specified by:
put in interface Cache<K,V>
Parameters:
key - key with which the specified value is associated
value - value to be associated with the specified key

remove

public void remove(K key)
Description copied from interface: Cache
Removes the mapping for a key from the cache if it is present.

Specified by:
remove in interface Cache<K,V>
Parameters:
key - key which mapping is to be removed from the cache, not null

clear

public void clear()
Description copied from interface: Cache
Clear the cache.

Specified by:
clear in interface Cache<K,V>

putAll

public void putAll(Map<K,V> map)
Specified by:
putAll in interface Cache<K,V>



Connector Packaging TECHNICAL 3.14.2 API
Copyright © {inceptionYear}-2018 eHealth. All Rights Reserved.