public synchronized E get ( K key ) { TTLObject < K , E > obj = getTTLObject ( key ) ; if ( obj != null && ! isExpired ( obj ) ) { if ( extendOnGet ) { extendTTL ( key ) ; } if ( eventListener != null ) { eventListener . onGet ( obj . getObject ( ) ) ; } obj . getObject ( ) . onGet ( ) ; return obj . getObject ( ) ; } else if ( obj != null ) { // Expired destroy ( obj . getKey ( ) ) ; obj = null ; } if ( obj == null ) { if ( objectFactory != null ) { E object = objectFactory . create ( key ) ; if ( object != null ) { if ( ! put ( key , object ) && logger != null ) { // We couldn't put this record.. just log a warning logger . warn ( "Failed to put object into cache. Cache size exceeded" ) ; } } return object ; } } return null ; }
Gets an object from cache . Returns null if the object does not exist or has expired .