接口缓存降级为实现类缓存

This commit is contained in:
zhaojun1998
2019-12-21 11:06:29 +08:00
parent e8122b4ed0
commit 0e6bcbfa11
6 changed files with 30 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import com.qcloud.cos.model.COSObjectSummary;
import com.qcloud.cos.model.ListObjectsRequest;
import com.qcloud.cos.model.ObjectListing;
import com.qcloud.cos.region.Region;
import im.zhaojun.common.config.ZFileCacheConfiguration;
import im.zhaojun.common.model.StorageConfig;
import im.zhaojun.common.model.dto.FileItemDTO;
import im.zhaojun.common.model.enums.FileTypeEnum;
@@ -19,6 +20,8 @@ import im.zhaojun.common.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -29,6 +32,7 @@ import java.util.List;
import java.util.Map;
@Service
@CacheConfig(cacheNames = ZFileCacheConfiguration.CACHE_NAME, keyGenerator = "keyGenerator")
public class TencentServiceImpl implements FileService {
private static final Logger log = LoggerFactory.getLogger(TencentServiceImpl.class);
@@ -78,6 +82,7 @@ public class TencentServiceImpl implements FileService {
}
}
@Cacheable
@Override
public List<FileItemDTO> fileList(String path) {
path = StringUtils.removeFirstSeparator(path);
@@ -106,6 +111,7 @@ public class TencentServiceImpl implements FileService {
return fileItemList;
}
@Cacheable
@Override
public String getDownloadUrl(String path) {
Date expirationDate = new Date(System.currentTimeMillis() + timeout * 1000);