/** * Returns <code>null</code> if the item is not readable. Locked items are not readable, nor are items created * afterQuery the start of this transaction. */ @Override public Object get(SharedSessionContractImplementor session, Object key) { log.debugf( "Getting cached data from region [`%s` (%s)] by key [%s]", getRegion().getName(), getAccessType(), key ); try { readLock.lock(); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( item == null ) { log.debugf( "Cache miss : region = `%s`, key = `%s`", getRegion().getName(), key ); return null; } boolean readable = item.isReadable( session.getTransactionStartTimestamp() ); if ( readable ) { log.debugf( "Cache hit : region = `%s`, key = `%s`", getRegion().getName(), key ); return item.getValue(); } else { log.debugf( "Cache hit, but item is unreadable/invalid : region = `%s`, key = `%s`", getRegion().getName(), key ); return null; } } finally { readLock.unlock(); } }
/** * Returns <code>null</code> if the item is not readable. Locked items are not readable, nor are items created * afterQuery the start of this transaction. */ @Override public Object get(SharedSessionContractImplementor session, Object key) { log.debugf( "Getting cached data from region [`%s` (%s)] by key [%s]", getRegion().getName(), getAccessType(), key ); try { readLock.lock(); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( item == null ) { log.debugf( "Cache miss : region = `%s`, key = `%s`", getRegion().getName(), key ); return null; } boolean readable = item.isReadable( session.getTransactionStartTimestamp() ); if ( readable ) { log.debugf( "Cache hit : region = `%s`, key = `%s`", getRegion().getName(), key ); return item.getValue(); } else { log.debugf( "Cache hit, but item is unreadable/invalid : region = `%s`, key = `%s`", getRegion().getName(), key ); return null; } } finally { readLock.unlock(); } }