/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection.maps;

import java.time.Duration;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public interface Cache<K,V> {

    static <K,V> Cache<K,V> getInstance() {
        return CacheMap.getInstance(e -> { throw new UnsupportedOperationException(); });
    }

    static <K,V> Cache<K,V> getInstance(int capacity) {
        return CacheMap.getInstance(capacity, e -> { throw new UnsupportedOperationException(); });
    }

    static <K,V> Cache<K,V> getInstance(Duration ttl) {
        return CacheMap.getInstance(ttl, e -> { throw new UnsupportedOperationException(); });
    }

    V get(K key, Function<K,V> function);

    V get(K key, Supplier<V> function);

    void clear();
}
