Class IdNameCache<T>
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.cache.IdNameCache<T>
-
- Type Parameters:
T- the type of the key value held by the cache
- All Implemented Interfaces:
IIdNameCache<T>
public class IdNameCache<T> extends java.lang.Object implements IIdNameCache<T>
-
-
Constructor Summary
Constructors Constructor Description IdNameCache()Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEntry(T id, java.lang.String name)Add the entry to the local cachevoidclearLocalMaps()Clear anything cached in thread-local (after transaction rollback, for example)java.util.Collection<java.lang.String>getAllNames()Get all names in the cachejava.lang.StringgetName(T key)Get the name for the given idvoidprefill(java.util.Map<T,java.lang.String> content)Prefill the shared map with the given content (must come data already committed in the database)voidreset()Clear both local shared caches - useful for unit testsvoidupdateSharedMaps()Called after a transaction commit() to transfer all the staged (thread-local) data over to the shared cache.
-
-
-
Method Detail
-
updateSharedMaps
public void updateSharedMaps()
Description copied from interface:IIdNameCacheCalled after a transaction commit() to transfer all the staged (thread-local) data over to the shared cache.- Specified by:
updateSharedMapsin interfaceIIdNameCache<T>
-
getName
public java.lang.String getName(T key)
Description copied from interface:IIdNameCacheGet the name for the given id- Specified by:
getNamein interfaceIIdNameCache<T>- Returns:
-
getAllNames
public java.util.Collection<java.lang.String> getAllNames()
Description copied from interface:IIdNameCacheGet all names in the cache- Specified by:
getAllNamesin interfaceIIdNameCache<T>- Returns:
-
addEntry
public void addEntry(T id, java.lang.String name)
Description copied from interface:IIdNameCacheAdd the entry to the local cache- Specified by:
addEntryin interfaceIIdNameCache<T>
-
reset
public void reset()
Description copied from interface:IIdNameCacheClear both local shared caches - useful for unit tests- Specified by:
resetin interfaceIIdNameCache<T>
-
clearLocalMaps
public void clearLocalMaps()
Description copied from interface:IIdNameCacheClear anything cached in thread-local (after transaction rollback, for example)- Specified by:
clearLocalMapsin interfaceIIdNameCache<T>
-
prefill
public void prefill(java.util.Map<T,java.lang.String> content)
Description copied from interface:IIdNameCachePrefill the shared map with the given content (must come data already committed in the database)- Specified by:
prefillin interfaceIIdNameCache<T>
-
-