Caching pattern: Refactor shutdown hook to use method reference
This commit is contained in:
@ -64,12 +64,7 @@ public final class AppManager {
|
||||
public static void initCachingPolicy(CachingPolicy policy) {
|
||||
cachingPolicy = policy;
|
||||
if (cachingPolicy == CachingPolicy.BEHIND) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CacheStore.flushCache();
|
||||
}
|
||||
}));
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(CacheStore::flushCache));
|
||||
}
|
||||
CacheStore.clearCache();
|
||||
}
|
||||
|
Reference in New Issue
Block a user