Added static method to clear specific cache
This commit is contained in:
parent
12e6f5ea75
commit
41fe221e3c
@ -32,20 +32,21 @@ import dorkbox.os.OS;
|
|||||||
public
|
public
|
||||||
class CacheUtil {
|
class CacheUtil {
|
||||||
|
|
||||||
private static final ThreadLocal<MessageDigest> digestLocal = new ThreadLocal<MessageDigest>() {
|
private static final ThreadLocal<MessageDigest> digestLocal = ThreadLocal.withInitial(()->{
|
||||||
@Override
|
|
||||||
protected
|
|
||||||
MessageDigest initialValue() {
|
|
||||||
try {
|
try {
|
||||||
return MessageDigest.getInstance("SHA1");
|
return MessageDigest.getInstance("SHA1");
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException("Unable to initialize hash algorithm. SHA1 digest doesn't exist?!? (This should not happen");
|
throw new RuntimeException("Unable to initialize hash algorithm. SHA1 digest doesn't exist?!? (This should not happen");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
private final String tempDir;
|
private final String tempDir;
|
||||||
|
|
||||||
|
public static
|
||||||
|
void clear(String tempDir) {
|
||||||
|
new CacheUtil(tempDir).clear();
|
||||||
|
}
|
||||||
|
|
||||||
public CacheUtil() {
|
public CacheUtil() {
|
||||||
this("cache");
|
this("cache");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user