/** * 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(); } }
Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( item != null && item.isUnlockable( lock ) ) { SoftLockImpl lockItem = (SoftLockImpl) item; if ( lockItem.wasLockedConcurrently() ) {
Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); boolean writable = item == null || item.isWriteable( session.getTransactionStartTimestamp(), version, getVersionComparator() ); if ( writable ) { getStorageAccess().putIntoCache(
Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( item != null && item.isUnlockable( lock ) ) { SoftLockImpl lockItem = (SoftLockImpl) item; if ( lockItem.wasLockedConcurrently() ) {
Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); boolean writable = item == null || item.isWriteable( session.getTransactionStartTimestamp(), version, getVersionComparator() ); if ( writable ) { getStorageAccess().putIntoCache(
Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( item != null && item.isUnlockable( lock ) ) { SoftLockImpl lockItem = (SoftLockImpl) item; if ( lockItem.wasLockedConcurrently() ) {
/** * 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(); } }
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) { try { writeLock.lock(); long timeout = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); log.debugf( "Locking cache item [region=`%s` (%s)] : `%s` (timeout=%s, version=%s)", getRegion().getName(), getAccessType(), key, timeout, version ); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); final SoftLockImpl lock = ( item == null ) ? new SoftLockImpl( timeout, uuid, nextLockId(), version ) : item.lock( timeout, uuid, nextLockId() ); getStorageAccess().putIntoCache( key, lock, session ); return lock; } finally { writeLock.unlock(); } }
@Override public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) { try { log.debugf( "Unlocking cache item [region=`%s` (%s)] : %s", getRegion().getName(), getAccessType(), key ); writeLock.lock(); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( ( item != null ) && item.isUnlockable( lock ) ) { decrementLock( session, key, (SoftLockImpl) item ); } else { handleLockExpiry( session, key, item ); } } finally { writeLock.unlock(); } }
Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( item != null && item.isUnlockable( lock ) ) { SoftLockImpl lockItem = (SoftLockImpl) item; if ( lockItem.wasLockedConcurrently() ) {
@Override public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) { try { log.debugf( "Unlocking cache item [region=`%s` (%s)] : %s", getRegion().getName(), getAccessType(), key ); writeLock.lock(); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); if ( ( item != null ) && item.isUnlockable( lock ) ) { decrementLock( session, key, (SoftLockImpl) item ); } else { handleLockExpiry( session, key, item ); } } finally { writeLock.unlock(); } }
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) { try { writeLock.lock(); long timeout = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); log.debugf( "Locking cache item [region=`%s` (%s)] : `%s` (timeout=%s, version=%s)", getRegion().getName(), getAccessType(), key, timeout, version ); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); final SoftLockImpl lock = ( item == null ) ? new SoftLockImpl( timeout, uuid, nextLockId(), version ) : item.lock( timeout, uuid, nextLockId() ); getStorageAccess().putIntoCache( key, lock, session ); return lock; } finally { writeLock.unlock(); } }