package com.coreoz.plume.file.services.cache;

import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import javax.inject.Singleton;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;

@Singleton
public class FileCacheServiceGuava implements FileCacheService {

	@Override
	public LoadingCache<Long, CachedFile> newCache(Function<Long, CachedFile> loadingData) {
		return CacheBuilder
			.newBuilder()
			.expireAfterWrite(1, TimeUnit.HOURS)
			.maximumSize(100)
			.build(CacheLoader.from(loadingData::apply));
	}

}

@@ -518,13 +518,14 @@
 fter
-Write
+Access
 (1, 
@@ -537,12 +537,11 @@
 nit.
-HOUR
+DAY
 S)%0A%09

Remove only unused files from cache