Explorar el Código

update 缓存方式

A17404李放 hace 3 años
padre
commit
1c4d77b9fb

+ 1 - 1
nb-admin/src/main/resources/application-dev.yml

@@ -120,6 +120,6 @@ aliyun:
   # iotInstanceId:企业版实例请填写实例ID,公共实例请填空字符串""。
   iotInstanceId: ""
   server-subscription:
-    enable: true  # 是否开启阿里云物联网服务端订阅
+    enable: false  # 是否开启阿里云物联网服务端订阅
   product:
     productKey: a1ALlsBa2ZK

+ 5 - 3
nb-system/src/main/java/com/coffee/bus/registry/Operator.java

@@ -3,6 +3,7 @@ package com.coffee.bus.registry;
 
 import com.coffee.common.cache.ConfigStorage;
 import com.coffee.common.cache.value.Value;
+import org.redisson.api.RMap;
 import org.redisson.api.RMapCache;
 import org.springframework.util.ReflectionUtils;
 
@@ -24,7 +25,7 @@ public interface Operator {
      */
     long DEFAULT_TTL=2;
 
-    RMapCache<String, Value> getCache();
+    RMap<String, Value> getCache();
 
     default Value wrapperValue(Object value){
         return Value.simple(value);
@@ -42,7 +43,8 @@ public interface Operator {
     }
 
     default void put(String key,Value value){
-        getCache()
-                .put(key,value,DEFAULT_TTL, TimeUnit.HOURS);
+//        getCache()
+//                .put(key,value,DEFAULT_TTL, TimeUnit.HOURS);
+        getCache().put(key,value);
     }
 }

+ 6 - 4
nb-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java

@@ -11,6 +11,9 @@ import com.coffee.bus.service.LocalBusDeviceService;
 import com.coffee.bus.service.LocalBusInfusionHistoryService;
 import com.coffee.common.cache.value.Value;
 import com.coffee.common.util.RedissonUtil;
+import org.redisson.api.LocalCachedMapOptions;
+import org.redisson.api.RLocalCachedMap;
+import org.redisson.api.RMap;
 import org.redisson.api.RMapCache;
 import java.math.BigDecimal;
 import java.util.Date;
@@ -25,8 +28,7 @@ import java.util.Date;
 public class ClusterDeviceOperator implements DeviceOperator {
 
     private final String deviceId;
-    private final RMapCache<String, Value> mapCache;
-
+    private final RMap<String, Value> mapCache;
     private final LocalBusDeviceService deviceService;
     private final LocalBusInfusionHistoryService infusionHistoryService;
 
@@ -35,11 +37,11 @@ public class ClusterDeviceOperator implements DeviceOperator {
         deviceService= SpringUtil.getBean(LocalBusDeviceService.class);
         infusionHistoryService=SpringUtil.getBean(LocalBusInfusionHistoryService.class);
         this.deviceId=deviceId;
-        this.mapCache= SpringUtil.getBean(RedissonUtil.class).getRedissonClient().getMapCache(key);
+        mapCache = SpringUtil.getBean(RedissonUtil.class).getRedissonClient().getLocalCachedMap(key, LocalCachedMapOptions.defaults());
     }
 
     @Override
-    public RMapCache<String, Value> getCache() {
+    public RMap<String, Value> getCache() {
         return mapCache;
     }
 

+ 6 - 3
nb-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientOperator.java

@@ -10,6 +10,9 @@ import com.coffee.bus.service.LocalBusInfusionHistoryService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.common.cache.value.Value;
 import com.coffee.common.util.RedissonUtil;
+import org.redisson.api.LocalCachedMapOptions;
+import org.redisson.api.RLocalCachedMap;
+import org.redisson.api.RMap;
 import org.redisson.api.RMapCache;
 
 /**
@@ -22,7 +25,7 @@ import org.redisson.api.RMapCache;
 public class ClusterPatientOperator implements PatientOperator {
     private final String patientCode;
     private final String hospitalId;
-    private final RMapCache<String, Value> mapCache;
+    private final RMap<String, Value> mapCache;
     private final LocalBusPatientService patientService;
     private final LocalBusInfusionHistoryService infusionHistoryService;
 
@@ -31,12 +34,12 @@ public class ClusterPatientOperator implements PatientOperator {
         this.hospitalId=hospitalId;
         patientService=SpringUtil.getBean(LocalBusPatientService.class);
         infusionHistoryService=SpringUtil.getBean(LocalBusInfusionHistoryService.class);
-        mapCache= SpringUtil.getBean(RedissonUtil.class).getRedissonClient().getMapCache(hospitalId+":"+patientCode);
+        mapCache = SpringUtil.getBean(RedissonUtil.class).getRedissonClient().getLocalCachedMap(hospitalId+":"+patientCode, LocalCachedMapOptions.defaults());
     }
 
 
     @Override
-    public RMapCache<String, Value> getCache() {
+    public RMap<String, Value> getCache() {
         return mapCache;
     }