@Override @SuppressWarnings({ "unchecked" }) public List get( final QueryKey key, final String[] spaces, final SharedSessionContractImplementor session) throws HibernateException { if ( DEBUGGING ) { LOG.debugf( "Checking cached query results in region: %s", cacheRegion.getName() ); } final CacheItem cacheItem = getCachedData( key, session ); if ( cacheItem == null ) { if ( DEBUGGING ) { LOG.debug( "Query results were not found in cache" ); } return null; } if ( !timestampsCache.isUpToDate( spaces, cacheItem.timestamp, session ) ) { if ( DEBUGGING ) { LOG.debug( "Cached query results were not up-to-date" ); } return null; } if ( DEBUGGING ) { LOG.debug( "Returning cached query results" ); } return deepCopy( cacheItem.results ); }
@Override @SuppressWarnings({ "unchecked" }) public List get( final QueryKey key, final Set<String> spaces, final SharedSessionContractImplementor session) throws HibernateException { if ( DEBUGGING ) { LOG.debugf( "Checking cached query results in region: %s", cacheRegion.getName() ); } final CacheItem cacheItem = getCachedData( key, session ); if ( cacheItem == null ) { if ( DEBUGGING ) { LOG.debug( "Query results were not found in cache" ); } return null; } if ( !timestampsCache.isUpToDate( spaces, cacheItem.timestamp, session ) ) { if ( DEBUGGING ) { LOG.debug( "Cached query results were not up-to-date" ); } return null; } if ( DEBUGGING ) { LOG.debug( "Returning cached query results" ); } return deepCopy( cacheItem.results ); }
@Override @SuppressWarnings({ "unchecked" }) public boolean put( final QueryKey key, final List results, final SharedSessionContractImplementor session) throws HibernateException { if ( DEBUGGING ) { LOG.debugf( "Caching query results in region: %s; timestamp=%s", cacheRegion.getName(), session.getTransactionStartTimestamp() ); } final CacheItem cacheItem = new CacheItem( session.getTransactionStartTimestamp(), deepCopy( results ) ); try { session.getEventListenerManager().cachePutStart(); cacheRegion.putIntoCache( key, cacheItem, session ); } finally { session.getEventListenerManager().cachePutEnd(); } return true; }