From f3e81b9bfb28732c3232ad1d6c6875308e670fb7 Mon Sep 17 00:00:00 2001 From: johnniang Date: Tue, 10 Dec 2019 23:45:50 +0800 Subject: [PATCH] Clear cache before application id destroyed --- src/main/java/run/halo/app/cache/InMemoryCacheStore.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/run/halo/app/cache/InMemoryCacheStore.java b/src/main/java/run/halo/app/cache/InMemoryCacheStore.java index b492c2215..f358ee461 100644 --- a/src/main/java/run/halo/app/cache/InMemoryCacheStore.java +++ b/src/main/java/run/halo/app/cache/InMemoryCacheStore.java @@ -67,8 +67,8 @@ public class InMemoryCacheStore extends StringCacheStore { log.debug("Preparing to put key: [{}], value: [{}]", key, cacheWrapper); + lock.lock(); try { - lock.lock(); // Get the value before Optional valueOptional = get(key); @@ -98,6 +98,11 @@ public class InMemoryCacheStore extends StringCacheStore { public void preDestroy() { log.debug("Cancelling all timer tasks"); timer.cancel(); + clear(); + } + + private void clear() { + CACHE_CONTAINER.clear(); } /**