use of info.evelio.carbonite.cache.MemoryLruCache in project carbonite by eveliotc.
the class CacheFactoryImp method buildDefault.
@SuppressWarnings("unchecked")
private Cache<String, T> buildDefault(CacheBuilder options) {
final CacheType cacheType = options.cacheType();
switch(cacheType) {
case MEMORY:
return new MemoryLruCache<String, T>(new MemoryLruCache.Options(LRU_SIZE));
case STORAGE:
// TODO yikes a builder or something, plus kryo needs more config
final Class type = options.type();
final File dir = buildCacheDir(options.context(), type);
final Serializer<T> serializer = new KryoSerializer<T>(new Kryo(), type);
final Options storageOpts = new Options(dir, MINIMAL_CAPACITY, type, serializer);
return new StorageLruCache<T>(storageOpts);
default:
illegalState(true, "Not yet implemented cache type " + cacheType);
return null;
}
}
Aggregations