public void put ( final K key , final V newValue ) { if ( newValue == null || ! newValue . isCurrent ( key ) ) { if ( LOG . isWarnEnabled ( ) ) { LOG . warn ( "Ignoring new cache entry for '{}' because it is {}" , key , ( newValue == null ? "null" : "not current" ) ) ; } return ; } V oldValue = cacheMap . get ( key ) ; if ( oldValue != null && oldValue . isNewerThan ( newValue ) ) { if ( LOG . isWarnEnabled ( ) ) { LOG . warn ( "Ignoring new cache entry for '{}' because " + "existing cache entry is newer" , key ) ; } return ; } // no existing value or new value is newer than old value oldValue = cacheMap . put ( key , newValue ) ; if ( LOG . isDebugEnabled ( ) ) { if ( oldValue == null ) { LOG . debug ( "Added new cache entry for '{}'" , key ) ; } else { LOG . debug ( "Overwrote existing cache entry for '{}'" , key ) ; } } }
Associates the specified value with the specified key in this cache . The value is only inserted if it is not null and it is considered current . If the cache previously contained a mapping for the key the old value is replaced only if the new value is newer than the old one .