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

com.testvagrant.optimus.cache.DataCache Maven / Gradle / Ivy

Go to download

Optimus Lite API to manage test devices and create appium driver based on platform

There is a newer version: 0.1.7-beta
Show newest version
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