Przeglądaj źródła

修复无法clear问题

zhou-hao 5 lat temu
rodzic
commit
4db481528c

+ 1 - 1
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/CaffeineReactiveCache.java

@@ -62,6 +62,6 @@ public class CaffeineReactiveCache<E> implements ReactiveCache<E> {
 
     @Override
     public Mono<Void> clear() {
-        return Mono.fromRunnable(() -> cache.cleanUp());
+        return Mono.fromRunnable(() -> cache.invalidateAll());
     }
 }

+ 1 - 1
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/GuavaReactiveCache.java

@@ -62,6 +62,6 @@ public class GuavaReactiveCache<E> implements ReactiveCache<E> {
 
     @Override
     public Mono<Void> clear() {
-        return Mono.fromRunnable(() -> cache.cleanUp());
+        return Mono.fromRunnable(() -> cache.invalidateAll());
     }
 }

+ 14 - 0
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/UnSupportedReactiveCache.java

@@ -4,9 +4,13 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.hswebframework.web.cache.ReactiveCache;
 import org.reactivestreams.Publisher;
+import reactor.cache.CacheFlux;
+import reactor.cache.CacheMono;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.function.Supplier;
+
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class UnSupportedReactiveCache<E> implements ReactiveCache<E> {
 
@@ -40,4 +44,14 @@ public class UnSupportedReactiveCache<E> implements ReactiveCache<E> {
     public Mono<Void> clear() {
         return Mono.empty();
     }
+
+    @Override
+    public CacheMono.MonoCacheBuilderMapMiss<E> mono(Object key) {
+        return Supplier::get;
+    }
+
+    @Override
+    public CacheFlux.FluxCacheBuilderMapMiss<E> flux(Object key) {
+        return Supplier::get;
+    }
 }