Interface QueryResultsCache

  • All Known Implementing Classes:
    QueryResultsCacheImpl

    public interface QueryResultsCache
    Responsible for managing query result list caching in a specific query cache region. There may be multiple instances of QueryResultsCache, corresponding to second-level cache regions with distinct policies.

    A QueryResultsCache depends on the TimestampsCache to track invalidation of the query spaces (tables) which affect the cached queries. A cached query result list is considered stale if any one of the query spaces which affect the query results was invalidated since the result list was read from the database and stored in the query result cache.

    • Method Detail

      • put

        boolean put​(QueryKey key,
                    List<?> result,
                    SharedSessionContractImplementor session)
             throws HibernateException
        Store a result list of a query with the given QueryKey in the query result cache.
        Parameters:
        key - The cache key uniquely identifying the query and its bound parameter arguments
        result - The result list to cache
        session - The originating session
        Returns:
        Whether the put actually happened.
        Throws:
        HibernateException - Indicates a problem delegating to the underlying cache.
      • get

        List<?> get​(QueryKey key,
                    Set<String> spaces,
                    SharedSessionContractImplementor session)
             throws HibernateException
        Attempt to retrieve a cached query result list for the given QueryKey from the cache region, and then check if the cached results, if any, are stale. If there is no cached result list for the given key, or if the cached results are stale, return null.
        Parameters:
        key - The cache key uniquely identifying the query and its bound parameter arguments
        spaces - The query spaces which affect the results of the query (used to check if cached results are stale)
        session - The originating session
        Returns:
        The cached results; may be null if there are no cached results for the given key, or if the results are stale.
        Throws:
        HibernateException - Indicates a problem delegating to the underlying cache.
      • get

        List<?> get​(QueryKey key,
                    String[] spaces,
                    SharedSessionContractImplementor session)
             throws HibernateException
        Attempt to retrieve a cached query result list for the given QueryKey from the cache region, and then check if the cached results, if any, are stale. If there is no cached result list for the given key, or if the cached results are stale, return null.
        Parameters:
        key - The cache key uniquely identifying the query and its bound parameter arguments
        spaces - The query spaces which affect the results of the query (used to check if cached results are stale)
        session - The originating session
        Returns:
        The cached results; may be null.
        Throws:
        HibernateException - Indicates a problem delegating to the underlying cache.
      • clear

        default void clear()
                    throws CacheException
        Clear all items from this query result cache.
        Throws:
        CacheException - Indicates a problem delegating to the underlying cache.
      • destroy

        default void destroy()