/** {@inheritDoc} */ @Override public <K, V> V put(String cacheName, K key, V val, long ttl) { assert cacheName != null; assert key != null; assert ttl >= 0; long expire = ttl > 0 ? System.currentTimeMillis() + ttl : 0; CachedObject<V> obj = new CachedObject<>(expire, val); Map<K, CachedObject<V>> cache = getOrCreateCache(cacheName); CachedObject<V> prev = cache.put(key, obj); return prev != null ? prev.obj : null; }