Interface PreparedParamCache
- All Known Implementing Classes:
MapPreparedParamCache
public interface PreparedParamCache
A contract that ensures the caching of prepared parameters (PreparedParameter).
The parametric engine gets PreparedParameter objects based on name.
It uses implementations of this interface for this purpose.
The cache implementation must be thread-safe .
The cache implementation must meet a "happen-before relationship" between threads for read and write operations.
ie. MapPreparedParamCache is build on top of ConcurrentHashMap, so it meets happens-before rules.
- Since:
- 1.0.0
- Author:
- Przemek Hertel
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns a parameter with defined nameparamNameornull, if parameter does not exist.voidInvalidate all entries from a cachevoidinvalidate(int id) Removes entry with a given [id] from a cachevoidinvalidate(String paramName) Removes entry with given name.list()Returns all cache entries as snapshot.voidput(String paramName, PreparedParameter pp) Inserts a parameterppunder a keyparamName.
-
Method Details
-
put
Inserts a parameterppunder a keyparamName.- Parameters:
paramName- unique parameter name, used as a key for a cachepp- parameter to be stored in a cache
-
get
Returns a parameter with defined nameparamNameornull, if parameter does not exist.- Parameters:
paramName- name of parameter- Returns:
- parameter from a cache
-
invalidate
Removes entry with given name.- Parameters:
paramName- name of parameter
-
invalidate
void invalidate(int id) Removes entry with a given [id] from a cache- Parameters:
id- entry id
-
invalidate
void invalidate()Invalidate all entries from a cache -
list
List<CacheEntry<PreparedParameter>> list()Returns all cache entries as snapshot. All modification to this snapshot will not modify cache state.- Returns:
- all cache entries as snapshot
-