* use proper caches

This commit is contained in:
Reinhard Pointner 2012-07-24 19:54:26 +00:00
parent 44cd76bae1
commit d33a907f2f
3 changed files with 20 additions and 4 deletions

View File

@ -34,14 +34,14 @@
/> />
<!-- <!--
Short-lived (48 hours) persistent disk cache for full web pages Long-lived (1 week) persistent disk cache for full web pages
--> -->
<cache name="web-data-diskcache" <cache name="web-data-diskcache"
maxElementsInMemory="50" maxElementsInMemory="50"
maxElementsOnDisk="5000" maxElementsOnDisk="5000"
eternal="false" eternal="false"
timeToIdleSeconds="172800" timeToIdleSeconds="604800"
timeToLiveSeconds="172800" timeToLiveSeconds="604800"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="true" diskPersistent="true"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"

View File

@ -28,6 +28,8 @@ import java.util.regex.Pattern;
import javax.swing.Icon; import javax.swing.Icon;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.web.TMDbClient.MovieInfo; import net.sourceforge.filebot.web.TMDbClient.MovieInfo;
import net.sourceforge.filebot.web.TMDbClient.MovieInfo.MovieProperty; import net.sourceforge.filebot.web.TMDbClient.MovieInfo.MovieProperty;
@ -195,6 +197,12 @@ public class IMDbClient implements MovieIdentificationService {
} }
return attr; return attr;
} }
@Override
protected Cache getCache() {
return CacheManager.getInstance().getCache("web-data-diskcache");
}
}; };
return data.get(); return data.get();

View File

@ -27,6 +27,8 @@ import java.util.logging.Logger;
import javax.swing.Icon; import javax.swing.Icon;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.web.TMDbClient.MovieInfo.MovieProperty; import net.sourceforge.filebot.web.TMDbClient.MovieInfo.MovieProperty;
import net.sourceforge.filebot.web.TMDbClient.Person.PersonProperty; import net.sourceforge.filebot.web.TMDbClient.Person.PersonProperty;
@ -42,7 +44,7 @@ public class TMDbClient implements MovieIdentificationService {
private static final String version = "3"; private static final String version = "3";
private static final FloodLimit SEARCH_LIMIT = new FloodLimit(10, 12, TimeUnit.SECONDS); private static final FloodLimit SEARCH_LIMIT = new FloodLimit(10, 12, TimeUnit.SECONDS);
private static final FloodLimit REQUEST_LIMIT = new FloodLimit(30, 12, TimeUnit.SECONDS); private static final FloodLimit REQUEST_LIMIT = new FloodLimit(20, 12, TimeUnit.SECONDS);
private final String apikey; private final String apikey;
@ -242,6 +244,12 @@ public class TMDbClient implements MovieIdentificationService {
} }
return super.fetchData(url, lastModified); return super.fetchData(url, lastModified);
} }
@Override
protected Cache getCache() {
return CacheManager.getInstance().getCache("web-data-diskcache");
}
}; };
return (JSONObject) JSONValue.parse(json.get()); return (JSONObject) JSONValue.parse(json.get());