Package org.hibernate.cache.spi
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 ofQueryResultsCache
, corresponding to second-level cache regions with distinct policies.A
QueryResultsCache
depends on theTimestampsCache
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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
clear()
Clear all items from this query result cache.default void
destroy()
List<?>
get(QueryKey key, String[] spaces, SharedSessionContractImplementor session)
Attempt to retrieve a cached query result list for the givenQueryKey
from the cache region, and then check if the cached results, if any, are stale.List<?>
get(QueryKey key, Set<String> spaces, SharedSessionContractImplementor session)
Attempt to retrieve a cached query result list for the givenQueryKey
from the cache region, and then check if the cached results, if any, are stale.QueryResultsRegion
getRegion()
The underlying cache region being used.boolean
put(QueryKey key, List<?> result, SharedSessionContractImplementor session)
Store a result list of a query with the givenQueryKey
in the query result cache.
-
-
-
Method Detail
-
getRegion
QueryResultsRegion getRegion()
The underlying cache region being used.
-
put
boolean put(QueryKey key, List<?> result, SharedSessionContractImplementor session) throws HibernateException
Store a result list of a query with the givenQueryKey
in the query result cache.- Parameters:
key
- The cache key uniquely identifying the query and its bound parameter argumentsresult
- The result list to cachesession
- 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 givenQueryKey
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, returnnull
.- Parameters:
key
- The cache key uniquely identifying the query and its bound parameter argumentsspaces
- 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 givenQueryKey
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, returnnull
.- Parameters:
key
- The cache key uniquely identifying the query and its bound parameter argumentsspaces
- 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()
-
-