CaffeineGetterCache.java

58 lines | 1.332 kB Blame History Raw Download
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrgs.inf.prosoft.cache;

import java.util.function.Supplier;

/**
 *
 * @author root
 * @param <V>
 */
public class CaffeineGetterCache<V> extends CaffeineSingleCache<Void, V> {

    public CaffeineGetterCache(String name) {
        super(name);
    }

    public CaffeineGetterCache(String name, long ttl) {
        super(name, ttl);
    }

    public CaffeineGetterCache(CachePerformance cachingPerformance) {
        super(cachingPerformance);
    }

    public CaffeineGetterCache(CachePerformance cachingPerformance, long ttl) {
        super(cachingPerformance, ttl);
    }

    public void put(V value, long timeToLive) {
        super.put(null, value, timeToLive);
    }

    public void put(V value) {
        super.put(null, value);
    }

    public V get() throws KeyNotFoundException {
        return super.get(null);
    }

    public void invalidate() {
        super.invalidate(null);
    }

    public V computeIfAbsent(Supplier<V> supplier, long timeToLive) {
        return super.computeIfAbsent(null, supplier, timeToLive);
    }

    public V computeIfAbsent(Supplier<V> supplier) {
        return super.computeIfAbsent(null, supplier);
    }

}