protected ItemData getItem ( final String identifier ) { long start = System . currentTimeMillis ( ) ; try { final CacheId k = new CacheId ( identifier ) ; final CacheValue v = cache . get ( k ) ; if ( v != null ) { final ItemData c = v . getItem ( ) ; if ( v . getExpiredTime ( ) > System . currentTimeMillis ( ) ) { // check if wasn't removed if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( name + ", getItem() " + identifier + " --> " + ( c != null ? c . getQPath ( ) . getAsString ( ) + " parent:" + c . getParentIdentifier ( ) : "[null]" ) ) ; } hits . incrementAndGet ( ) ; return c ; } // remove expired writeLock . lock ( ) ; try { cache . remove ( k ) ; // remove by parentId + path cache . remove ( new CacheQPath ( c . getParentIdentifier ( ) , c . getQPath ( ) , ItemType . getItemType ( c ) ) ) ; // remove cached child lists if ( c . isNode ( ) ) { nodesCache . remove ( c . getIdentifier ( ) ) ; propertiesCache . remove ( c . getIdentifier ( ) ) ; } } finally { writeLock . unlock ( ) ; } } miss . incrementAndGet ( ) ; return null ; } finally { totalGetTime += System . currentTimeMillis ( ) - start ; } }
Get item from cache C by item id . Checks is it expired calcs statistics .