* enforce heavy caching to save resources for the various webservices
This commit is contained in:
parent
d52ae6cab8
commit
67f6dc63e1
|
@ -1,5 +1,4 @@
|
|||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false">
|
||||
|
||||
<!--
|
||||
Persistent disk store location
|
||||
-->
|
||||
|
@ -7,7 +6,7 @@
|
|||
|
||||
<!--
|
||||
Mandatory Default Cache configuration. These settings will be applied to caches
|
||||
created pragmatically using CacheManager.add(String cacheName).
|
||||
created pragmatically using CacheManager.add(String cacheName)
|
||||
-->
|
||||
<defaultCache
|
||||
maxElementsInMemory="100"
|
||||
|
@ -20,52 +19,38 @@
|
|||
/>
|
||||
|
||||
<!--
|
||||
Short-lived (48 hours) persistent cache for web responses.
|
||||
Long-lived (2 week) persistent disk cache for web responses
|
||||
-->
|
||||
<cache name="web-datasource"
|
||||
maxElementsInMemory="200"
|
||||
maxElementsOnDisk="5000"
|
||||
maxElementsOnDisk="10000"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="172800"
|
||||
timeToLiveSeconds="172800"
|
||||
timeToIdleSeconds="1209600"
|
||||
timeToLiveSeconds="1209600"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Long-lived (1 week) persistent disk cache for full web pages
|
||||
Very long-lived cache (2 months) anime/series lists, movie index, etc
|
||||
-->
|
||||
<cache name="web-data-diskcache"
|
||||
<cache name="web-persistent-datasource"
|
||||
maxElementsInMemory="50"
|
||||
maxElementsOnDisk="5000"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="604800"
|
||||
timeToLiveSeconds="604800"
|
||||
timeToIdleSeconds="5259000"
|
||||
timeToLiveSeconds="5259000"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Very long-lived cache (one month!) anime/series list and episode information.
|
||||
-->
|
||||
<cache name="web-persistent-datasource"
|
||||
maxElementsInMemory="40"
|
||||
maxElementsOnDisk="240"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="2628000"
|
||||
timeToLiveSeconds="2628000"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Simple memory cache for calculated checksums. Time to live is 2 hours. This cache is used in EpisodeFormatBindingBean
|
||||
Simple memory cache for calculated checksums. Time to live is 2 hours.
|
||||
-->
|
||||
<cache name="checksum"
|
||||
maxElementsInMemory="4200"
|
||||
maxElementsInMemory="5000"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="7200"
|
||||
timeToLiveSeconds="7200"
|
||||
|
|
|
@ -70,7 +70,7 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
|||
|
||||
@Override
|
||||
public ResultCache getCache() {
|
||||
return new ResultCache(host, Cache.getCache("web-persistent-datasource"));
|
||||
return new ResultCache(host, Cache.getCache("web-datasource"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class CachedPage extends CachedResource<String> {
|
|||
|
||||
@Override
|
||||
protected Cache getCache() {
|
||||
return CacheManager.getInstance().getCache("web-data-diskcache");
|
||||
return CacheManager.getInstance().getCache("web-datasource");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ public abstract class CachedResource<T extends Serializable> {
|
|||
}
|
||||
|
||||
|
||||
public CachedResource(String resource, Class<T> type) {
|
||||
this(resource, type, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
protected Cache getCache() {
|
||||
return CacheManager.getInstance().getCache("web-persistent-datasource");
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class FanartTV {
|
|||
String resource = getResource(category, id, "xml", type, sort, limit);
|
||||
|
||||
// cache results
|
||||
CachedResource<FanartDescriptor[]> data = new CachedResource<FanartDescriptor[]>(resource, FanartDescriptor[].class, 7 * 24 * 60 * 60 * 1000) {
|
||||
CachedResource<FanartDescriptor[]> data = new CachedResource<FanartDescriptor[]>(resource, FanartDescriptor[].class) {
|
||||
|
||||
@Override
|
||||
public FanartDescriptor[] process(ByteBuffer data) throws Exception {
|
||||
|
@ -86,7 +86,7 @@ public class FanartTV {
|
|||
|
||||
@Override
|
||||
protected Cache getCache() {
|
||||
return CacheManager.getInstance().getCache("web-data-diskcache");
|
||||
return CacheManager.getInstance().getCache("web-datasource");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ public class IMDbClient implements MovieIdentificationService {
|
|||
public Map<String, String> getImdbApiData(Integer i, String t, String y, boolean tomatoes) throws IOException {
|
||||
// e.g. http://www.imdbapi.com/?i=tt0379786&r=xml&tomatoes=true
|
||||
String url = String.format("http://www.omdbapi.com/?i=%s&t=%s&y=%s&r=xml&tomatoes=%s", String.format(i == null ? "" : "tt%07d", i), t, y, tomatoes);
|
||||
CachedResource<HashMap> data = new CachedResource<HashMap>(url, HashMap.class, 7 * 24 * 60 * 60 * 1000) {
|
||||
CachedResource<HashMap> data = new CachedResource<HashMap>(url, HashMap.class) {
|
||||
|
||||
@Override
|
||||
public HashMap process(ByteBuffer data) throws Exception {
|
||||
|
@ -190,7 +190,7 @@ public class IMDbClient implements MovieIdentificationService {
|
|||
|
||||
@Override
|
||||
protected Cache getCache() {
|
||||
return CacheManager.getInstance().getCache("web-data-diskcache");
|
||||
return CacheManager.getInstance().getCache("web-datasource");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ public class TMDbClient implements MovieIdentificationService {
|
|||
|
||||
URL url = new URL("http", host, "/" + version + "/" + resource + "?" + encodeParameters(data, true));
|
||||
|
||||
CachedResource<String> json = new CachedResource<String>(url.toString(), String.class, 7 * 24 * 60 * 60 * 1000) {
|
||||
CachedResource<String> json = new CachedResource<String>(url.toString(), String.class) {
|
||||
|
||||
@Override
|
||||
public String process(ByteBuffer data) throws Exception {
|
||||
|
@ -263,7 +263,7 @@ public class TMDbClient implements MovieIdentificationService {
|
|||
|
||||
@Override
|
||||
protected Cache getCache() {
|
||||
return CacheManager.getInstance().getCache("web-data-diskcache");
|
||||
return CacheManager.getInstance().getCache("web-datasource");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class MyEpisodesScraper {
|
|||
def username
|
||||
def password
|
||||
|
||||
def cache = Cache.getCache('web-persistent-datasource')
|
||||
def cache = Cache.getCache('web-datasource')
|
||||
def session = [:]
|
||||
|
||||
def login = {
|
||||
|
|
Loading…
Reference in New Issue