mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
接口缓存降级为实现类缓存
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.hutool.core.util.URLUtil;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.*;
|
||||
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;
|
||||
@@ -14,6 +15,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;
|
||||
@@ -24,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = ZFileCacheConfiguration.CACHE_NAME, keyGenerator = "keyGenerator")
|
||||
public class AliyunServiceImpl implements FileService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AliyunServiceImpl.class);
|
||||
@@ -77,6 +81,7 @@ public class AliyunServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<FileItemDTO> fileList(String path) {
|
||||
path = StringUtils.removeFirstSeparator(path);
|
||||
|
||||
@@ -107,6 +112,7 @@ public class AliyunServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public String getDownloadUrl(String path) {
|
||||
path = StringUtils.removeFirstSeparator(path);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import im.zhaojun.common.util.StringUtils;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayDeque;
|
||||
@@ -18,10 +17,8 @@ import java.util.List;
|
||||
@CacheConfig(cacheNames = ZFileCacheConfiguration.CACHE_NAME, keyGenerator = "keyGenerator")
|
||||
public interface FileService {
|
||||
|
||||
@Cacheable(condition = "#root.targetClass.simpleName != 'LocalServiceImpl'")
|
||||
List<FileItemDTO> fileList(String path) throws Exception;
|
||||
|
||||
@Cacheable
|
||||
String getDownloadUrl(String path) throws Exception;
|
||||
|
||||
@PostConstruct
|
||||
|
||||
@@ -2,6 +2,7 @@ package im.zhaojun.ftp.service;
|
||||
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.extra.ftp.Ftp;
|
||||
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;
|
||||
@@ -12,6 +13,8 @@ import im.zhaojun.common.util.StringUtils;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -20,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = ZFileCacheConfiguration.CACHE_NAME, keyGenerator = "keyGenerator")
|
||||
public class FtpServiceImpl implements FileService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FtpServiceImpl.class);
|
||||
@@ -62,6 +66,7 @@ public class FtpServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<FileItemDTO> fileList(String path) {
|
||||
FTPFile[] ftpFiles = ftp.lsFiles(path);
|
||||
|
||||
@@ -83,6 +88,7 @@ public class FtpServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public String getDownloadUrl(String path) {
|
||||
return URLUtil.complateUrl(domain, path);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package im.zhaojun.huawei.service;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.obs.services.ObsClient;
|
||||
import com.obs.services.model.*;
|
||||
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;
|
||||
@@ -13,6 +14,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;
|
||||
@@ -22,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = ZFileCacheConfiguration.CACHE_NAME, keyGenerator = "keyGenerator")
|
||||
public class HuaweiServiceImpl implements FileService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HuaweiServiceImpl.class);
|
||||
@@ -69,6 +73,7 @@ public class HuaweiServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<FileItemDTO> fileList(String path) throws Exception {
|
||||
path = StringUtils.removeFirstSeparator(path);
|
||||
|
||||
@@ -107,6 +112,7 @@ public class HuaweiServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public String getDownloadUrl(String path) throws Exception {
|
||||
path = StringUtils.removeFirstSeparator(path);
|
||||
TemporarySignatureRequest req = new TemporarySignatureRequest(HttpMethodEnum.GET, timeout);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.qiniu.storage.Configuration;
|
||||
import com.qiniu.storage.model.FileInfo;
|
||||
import com.qiniu.storage.model.FileListing;
|
||||
import com.qiniu.util.Auth;
|
||||
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;
|
||||
@@ -17,6 +18,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;
|
||||
@@ -26,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = ZFileCacheConfiguration.CACHE_NAME, keyGenerator = "keyGenerator")
|
||||
public class QiniuServiceImpl implements FileService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QiniuServiceImpl.class);
|
||||
@@ -78,6 +82,7 @@ public class QiniuServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<FileItemDTO> fileList(String path) throws Exception {
|
||||
path = StringUtils.removeFirstSeparator(path);
|
||||
List<FileItemDTO> fileItemList = new ArrayList<>();
|
||||
@@ -119,6 +124,7 @@ public class QiniuServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public String getDownloadUrl(String path) {
|
||||
String url = URLUtil.complateUrl(domain, path);
|
||||
if (isPrivate) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user