Refactor
This commit is contained in:
parent
9fe2c81784
commit
3ea3045545
|
@ -22,7 +22,7 @@ public class Cache {
|
|||
public static final Duration ONE_MONTH = Duration.ofDays(30);
|
||||
|
||||
public static Cache getCache(String name, CacheType type) {
|
||||
return CacheManager.getInstance().getCache(name, type);
|
||||
return CacheManager.getInstance().getCache(name.toLowerCase() + "_" + type.ordinal(), type);
|
||||
}
|
||||
|
||||
public <T> CachedResource<T, byte[]> bytes(T key, Transform<T, URL> resource) {
|
||||
|
|
|
@ -36,12 +36,11 @@ public class CacheManager {
|
|||
}
|
||||
|
||||
public synchronized Cache getCache(String name, CacheType type) {
|
||||
String cacheName = name.toLowerCase() + "_" + type.ordinal();
|
||||
if (!manager.cacheExists(cacheName)) {
|
||||
debug.config("Create cache: " + cacheName);
|
||||
manager.addCache(new net.sf.ehcache.Cache(type.getConfiguration(cacheName)));
|
||||
if (!manager.cacheExists(name)) {
|
||||
debug.config("Create cache: " + name);
|
||||
manager.addCache(new net.sf.ehcache.Cache(type.getConfiguration(name)));
|
||||
}
|
||||
return new Cache(manager.getCache(cacheName));
|
||||
return new Cache(manager.getCache(name));
|
||||
}
|
||||
|
||||
public synchronized void clearAll() {
|
||||
|
|
|
@ -447,7 +447,7 @@ public class MediaBindingBean {
|
|||
|
||||
// calculate checksum from file
|
||||
Cache cache = Cache.getCache("crc32", CacheType.Ephemeral);
|
||||
return (String) cache.computeIfAbsent(inferredMediaFile, element -> crc32(inferredMediaFile));
|
||||
return (String) cache.computeIfAbsent(inferredMediaFile.getCanonicalPath(), it -> crc32(inferredMediaFile));
|
||||
}
|
||||
|
||||
@Define("fn")
|
||||
|
|
Loading…
Reference in New Issue