com.testvagrant.optimus.cache.DataCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optimus-lite Show documentation
Show all versions of optimus-lite Show documentation
Optimus Lite API to manage test devices and create appium driver based on platform
package com.testvagrant.optimus.cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
public abstract class DataCache {
protected LoadingCache build(CacheLoader cacheLoader) {
return CacheBuilder.newBuilder()
.maximumSize(100)
.expireAfterWrite(4, TimeUnit.HOURS)
.build(cacheLoader);
}
public abstract void put(Key key, Value value);
public abstract boolean isPresent(Predicate predicate);
public abstract Value get(Predicate predicate) throws ExecutionException;
protected abstract void lock(Key value);
public abstract void release(Key value);
public abstract long size();
protected boolean anyMatch(LoadingCache cache, Predicate predicate) {
return cache.asMap().values().stream().anyMatch(predicate);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy