
net.anthavio.cache.CacheEntryLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hatatitla Show documentation
Show all versions of hatatitla Show documentation
Compact but tweakable REST client library you have been dreaming of
The newest version!
package net.anthavio.cache;
/**
*
* @author martin.vanek
*
*/
public abstract class CacheEntryLoader {
/**
* To be implemented by subclass
*
* @param request
* @param async - flag of asynchronous execution
* @param expiredEntry - null on missing entry load
* @return
* @throws Exception
*/
protected abstract CacheEntryLoadResult load(CacheLoadRequest request, boolean async,
CacheEntry expiredEntry) throws Exception;
/**
* Product of CacheEntryLoader load method execution
*
* @author martin.vanek
*
* @param
*/
public static class CacheEntryLoadResult extends CacheEntry {
private static final long serialVersionUID = 1L;
private final boolean cacheSet;
public CacheEntryLoadResult(boolean cacheSet, V value, long evictTtl, long expireTtl) {
super(value, evictTtl, expireTtl);
this.cacheSet = cacheSet;
}
/*
public CacheEntryLoadResult(boolean cacheSet, V value, CacheLoadRequest request) {
this(cacheSet, value, request.getHardTtl(), request.getSoftTtl());
}
public CacheEntryLoadResult(boolean cacheSet, V value, CacheEntry expiredEntry) {
this(cacheSet, value, expiredEntry.getHardTtl(), expiredEntry.getSoftTtl());
}
*/
public boolean getCacheSet() {
return cacheSet;
}
@Override
public String toString() {
return super.toString() + " cacheSet=" + cacheSet;
}
}
/**
* Checked Exception wrapper for ExceptionMode.RETHROW
*
* @author martin.vanek
*
*/
public static class CacheLoaderException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final CacheLoadRequest, ?> request;
public CacheLoaderException(Exception x, CacheLoadRequest, ?> request) {
super(x);
this.request = request;
}
public CacheLoadRequest, ?> getRequest() {
return request;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy