All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.erupt.core.cache.EruptCache Maven / Gradle / Ivy

There is a newer version: 1.12.17
Show newest version
package xyz.erupt.core.cache;

import java.util.Optional;
import java.util.function.Supplier;

/**
 * @author YuePeng
 * date 2021/3/23 14:09
 */
public interface EruptCache {

    V put(String key, V v, long ttl);

    V get(String key);

    default V getAndSet(String key, long timeout, Supplier supplier) {
        return Optional.ofNullable(this.get(key)).orElseGet(() -> this.put(key, supplier.get(), timeout));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy