package test.cache;

import java.util.Map.Entry;
import java.util.Optional;

/**
 * Additionally to {@link Cache} supports cache-aside cache via {@link #put(Object, Object)()}.
 *
 * @param <KEY  > Data key
 * @param <DATA > Value to store
 * @param <ENTRY> Associated cache entry
 * 
 * @author bpodchezertsev
 */
public interface WritableCache<
    KEY,
    DATA,
    ENTRY extends Entry<KEY, DATA>
> extends Cache<KEY, DATA, ENTRY> {

    /**
     * Put value to cache. Useful for cache-aside caches.
     * @param key Data key. Can't be null.
     * @param value Data value. Null support depends on implementation.
     * @return Optional new cache entry. Can be empty for LFU-type cache. Can't be empty for LRU-type cache.
     */
    Optional<ENTRY> put(KEY key, DATA value);
    
}
