private V setValueInsideWriteLock ( V newValue ) { CachedValue < V > cached = cachedValue ; // read the cached value V oldValue = cached != null ? cached . value : null ; if ( newValue != null ) { long expiresAt = ttlInMs > 0 ? U . time ( ) + ttlInMs : Long . MAX_VALUE ; cachedValue = new CachedValue <> ( newValue , expiresAt ) ; } else { cachedValue = null ; } return oldValue ; }
Sets new cached value executes inside already acquired write lock .