algoliasearch/src/main/java/com/algolia/search/saas/ExpiringCache.java
public V put(K key, V value) {
        V previous = null;

        synchronized (this) {
            long timeout = System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(expirationTimeout, expirationTimeUnit);
            final Pair<V, Long> previousPair = lruCache.put(key, new Pair<>(value, timeout));
            if (previousPair != null) {
                previous = previousPair.first;
            }
        }
        return previous;
    }
public V put(K key, V value) {
        V previous = null;

        synchronized (this) {
            long timeout = System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(expirationTimeout, expirationTimeUnit);
            final Pair<V, Long> previousPair = lruCache.put(key, new Pair<>(value, timeout));
            if (previousPair != null) {
                previous = previousPair.first;
            }
        }
        return previous;
    }
public V put ( K key , V value ) { V previous = null ; synchronized ( this ) { long timeout = System . currentTimeMillis ( ) + TimeUnit . MILLISECONDS . convert ( expirationTimeout , expirationTimeUnit ) ; final Pair < V , Long > previousPair = lruCache . put ( key , new Pair <> ( value , timeout ) ) ; if ( previousPair != null ) { previous = previousPair . first ; } } return previous ; }
Puts a value in the cache, computing an expiration time

@return the previous value for this key, if any
Puts a value in the cache computing an expiration time