Explorar el Código

caffeine 缓存配置

liuam hace 7 años
padre
commit
03ddae91af

+ 23 - 0
src/main/java/com/uas/ps/inquiry/config/CaffeineConfig.java

@@ -0,0 +1,23 @@
+package com.uas.ps.inquiry.config;
+
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author liuam
+ * @since 2018/11/7 0007 下午 16:32
+ */
+@Configuration
+public class CaffeineConfig {
+    @Bean
+    public CacheLoader<Object, Object> cacheLoader() {
+        CacheLoader<Object, Object> cacheLoader = new CacheLoader<Object, Object>() {
+            @Override
+            public Object load(Object key) throws Exception {
+                return null;
+            }
+        };
+        return cacheLoader;
+    }
+}

+ 1 - 1
src/main/resources/config/application-dev.properties

@@ -54,7 +54,7 @@ http.syncConnectPerRoute=500
 http.syncConnectNum=500
 
 #spring.cache.cache-names=inquiry_public
-spring.cache.caffeine.spec=maximumSize=1000,expireAfterAccess=10s
+spring.cache.caffeine.spec=maximumSize=1000,refreshAfterWrite=60s
 
 logging.level.org.springframework.jdbc=debug
 logging.level.org.springframework.cache=debug