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.

Author:
Przemek Hertel
Since:
1.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    findKey(int pid)
    Finds cache entry with given parameter id and returns cache key.
    get(String paramName)
    Returns a parameter with defined name paramName or null, if parameter does not exist.
    void
    Invalidate all entries from a cache
    void
    invalidate(int id)
    Removes entry with a given [id] from a cache
    void
    invalidate(String paramName)
    Removes entry with given name.
    Returns all cache entries as snapshot.
    void
    put(String paramName, PreparedParameter pp)
    Inserts a parameter pp under a key paramName.
    int
    Returns the number of cache entries.
  • Method Details

    • put

      void put(String paramName, PreparedParameter pp)
      Inserts a parameter pp under a key paramName.
      Parameters:
      paramName - unique parameter name, used as a key for a cache
      pp - parameter to be stored in a cache
    • get

      PreparedParameter get(String paramName)
      Returns a parameter with defined name paramName or null, if parameter does not exist.
      Parameters:
      paramName - name of parameter
      Returns:
      parameter from a cache
    • invalidate

      void invalidate(String paramName)
      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

      Returns all cache entries as snapshot. All modification to this snapshot will not modify cache state.
      Returns:
      all cache entries as snapshot
    • findKey

      String findKey(int pid)
      Finds cache entry with given parameter id and returns cache key. Returns null if there is no such parameter in the cache.
    • size

      int size()
      Returns the number of cache entries.