if ( log.isDebugEnabled() )
{
log.debug( "in cache get(key,container)" );
}
ICacheElement ce = null;
boolean found = false;
try
{
if ( log.isDebugEnabled() )
{
log.debug( "get: key = " + key + ", is local invocation = "
+ ( invocation == this.LOCAL_INVOKATION ) );
}
ce = ( ICacheElement ) memCache.get( key, true );
if ( ce == null )
{
// Item not found in memory. Try the auxiliary caches if local.
for ( int i = 0; i < auxCaches.length; i++ )
{
ICache aux = auxCaches[i];
if ( aux != null )
{
if ( ( invocation == this.LOCAL_INVOKATION ) || aux.getCacheType() == aux.DISK_CACHE )
{
if ( log.isDebugEnabled() )
{
log.debug( "get(key,container,invocation) > in local block, aux.getCacheType() = " + aux.getCacheType() );
}
try
{
ce = ( ICacheElement ) aux.get( key, true );
}
catch ( IOException ex )
{
handleException( ex );
}
}
if ( log.isDebugEnabled() )
{
log.debug( "ce = " + ce );
}
if ( ce != null )
{
found = true;
// Item found in one of the auxiliary caches.
auxHit[i]++;
if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- AUX[" + i + "]-HIT for " + key );
log.debug( "ce.getKey() = " + ce.getKey() );
log.debug( "ce.getVal() = " + ce.getVal() );
}
memCache.update( ce );
break;
}
}
// end for
}
// end if invocation = LOCAL
}
else
{
found = true;
ramHit++;
if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- RAM-HIT for " + key );
}
}
}
catch ( Exception e )
{
log.error( e );
}
try
{
if ( !found )
{
// Item not found in all caches.
miss++;
if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- MISS for " + key );
}
return null;
//throw new ObjectNotFoundException( key + " not found in cache" );
}
}
catch ( Exception e )
{
log.error( "Error handling miss", e );
return null;
}
// HUB Manages expiration
try
{
if ( !ce.getElementAttributes().getIsEternal() )
{
long now = System.currentTimeMillis();
// Exceeded maxLifeSeconds
if ( ( ce.getElementAttributes().getMaxLifeSeconds() != -1 ) && ( now - ce.getElementAttributes().getCreateTime() ) > ( ce.getElementAttributes().getMaxLifeSeconds() * 1000 ) )
{
if ( log.isInfoEnabled() )
{
log.info( "Exceeded maxLifeSeconds -- " + ce.getKey() );
}
this.remove( key );
//cache.remove( me.ce.getKey() );
return null;
}
else
// NOT SURE IF THIS REALLY BELONGS HERE. WHAT IS THE
// POINT OF IDLE TIME? SEEMS OK
// Exceeded maxIdleTime, removal
if ( ( ce.getElementAttributes().getIdleTime() != -1 ) && ( now - ce.getElementAttributes().getLastAccessTime() ) > ( ce.getElementAttributes().getIdleTime() * 1000 ) )
{
if ( log.isInfoEnabled() )
{
log.info( "Exceeded maxIdleTime [ ce.getElementAttributes().getIdleTime() = " + ce.getElementAttributes().getIdleTime() + " ]-- " + ce.getKey() );
}
this.remove( key );
//cache.remove( me.ce.getKey() );
return null;
}
}
}
catch ( Exception e )
{
log.error( "Error determining expiration period", e );
return null;
}
if ( container )
{
return ce;
}
else
{
return ce.getVal();
}
}