|
@@ -3,14 +3,12 @@ package com.fs.express.cache.impl;
|
|
|
import com.fs.express.FsStoreDeliversService;
|
|
import com.fs.express.FsStoreDeliversService;
|
|
|
import com.fs.express.cache.FsStoreDeliversCacheService;
|
|
import com.fs.express.cache.FsStoreDeliversCacheService;
|
|
|
import com.fs.store.domain.FsStoreDelivers;
|
|
import com.fs.store.domain.FsStoreDelivers;
|
|
|
-import com.fs.store.domain.FsUser;
|
|
|
|
|
import com.github.benmanes.caffeine.cache.Cache;
|
|
import com.github.benmanes.caffeine.cache.Cache;
|
|
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
@@ -18,11 +16,17 @@ import java.util.concurrent.TimeUnit;
|
|
|
public class FsStoreDeliversCacheServiceImpl implements FsStoreDeliversCacheService {
|
|
public class FsStoreDeliversCacheServiceImpl implements FsStoreDeliversCacheService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsStoreDeliversService fsStoreDeliversService;
|
|
private FsStoreDeliversService fsStoreDeliversService;
|
|
|
|
|
+
|
|
|
private static final Cache<Long, Integer> EXPRESS_STATUS_CACHE = Caffeine.newBuilder()
|
|
private static final Cache<Long, Integer> EXPRESS_STATUS_CACHE = Caffeine.newBuilder()
|
|
|
.maximumSize(1000)
|
|
.maximumSize(1000)
|
|
|
.expireAfterWrite(3, TimeUnit.MINUTES)
|
|
.expireAfterWrite(3, TimeUnit.MINUTES)
|
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
|
|
+ private static final Cache<String, FsStoreDelivers> ORDER_CODE_CACHE = Caffeine.newBuilder()
|
|
|
|
|
+ .maximumSize(1000)
|
|
|
|
|
+ .expireAfterWrite(3, TimeUnit.MINUTES)
|
|
|
|
|
+ .build();
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Integer findExpressStatusByOrderId(Long orderId) {
|
|
public Integer findExpressStatusByOrderId(Long orderId) {
|
|
|
EXPRESS_STATUS_CACHE.get(orderId, key -> {
|
|
EXPRESS_STATUS_CACHE.get(orderId, key -> {
|
|
@@ -36,4 +40,9 @@ public class FsStoreDeliversCacheServiceImpl implements FsStoreDeliversCacheServ
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public FsStoreDelivers findByOrderCode(String orderCode) {
|
|
|
|
|
+ return ORDER_CODE_CACHE.get(orderCode, key -> fsStoreDeliversService.findByOrderCode(orderCode));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|