|
@@ -6,6 +6,7 @@ import cn.reghao.dfs.store.db.mapper.FileMetaMapper;
|
|
|
import cn.reghao.dfs.store.model.po.ContentRange;
|
|
import cn.reghao.dfs.store.model.po.ContentRange;
|
|
|
import cn.reghao.dfs.store.model.po.DataBlock;
|
|
import cn.reghao.dfs.store.model.po.DataBlock;
|
|
|
import cn.reghao.dfs.store.model.po.FileMeta;
|
|
import cn.reghao.dfs.store.model.po.FileMeta;
|
|
|
|
|
+import cn.reghao.dfs.store.redis.ds.RedisStringObj;
|
|
|
import cn.reghao.jutil.jdk.security.DigestUtil;
|
|
import cn.reghao.jutil.jdk.security.DigestUtil;
|
|
|
import cn.reghao.jutil.tool.id.IdGenerator;
|
|
import cn.reghao.jutil.tool.id.IdGenerator;
|
|
|
import cn.reghao.jutil.web.ServletUtil;
|
|
import cn.reghao.jutil.web.ServletUtil;
|
|
@@ -44,10 +45,12 @@ public class ObjectBasicService {
|
|
|
private final FileUrlService fileUrlService;
|
|
private final FileUrlService fileUrlService;
|
|
|
private final FileTypeService fileTypeService;
|
|
private final FileTypeService fileTypeService;
|
|
|
private final LocalCache localCache;
|
|
private final LocalCache localCache;
|
|
|
|
|
+ private final RedisStringObj redisStringObj;
|
|
|
|
|
|
|
|
public ObjectBasicService(FileMetaMapper fileMetaMapper, DataBlockMapper dataBlockMapper,
|
|
public ObjectBasicService(FileMetaMapper fileMetaMapper, DataBlockMapper dataBlockMapper,
|
|
|
FileStoreService fileStoreService, FileUrlService fileUrlService,
|
|
FileStoreService fileStoreService, FileUrlService fileUrlService,
|
|
|
- FileTypeService fileTypeService, LocalCache localCache) {
|
|
|
|
|
|
|
+ FileTypeService fileTypeService, LocalCache localCache,
|
|
|
|
|
+ RedisStringObj redisStringObj) {
|
|
|
this.objectIdGenerator = new IdGenerator(32, "object-id");
|
|
this.objectIdGenerator = new IdGenerator(32, "object-id");
|
|
|
this.blockIdGenerator = new IdGenerator(32, "block-id");
|
|
this.blockIdGenerator = new IdGenerator(32, "block-id");
|
|
|
this.fileMetaMapper = fileMetaMapper;
|
|
this.fileMetaMapper = fileMetaMapper;
|
|
@@ -56,6 +59,7 @@ public class ObjectBasicService {
|
|
|
this.fileUrlService = fileUrlService;
|
|
this.fileUrlService = fileUrlService;
|
|
|
this.fileTypeService = fileTypeService;
|
|
this.fileTypeService = fileTypeService;
|
|
|
this.localCache = localCache;
|
|
this.localCache = localCache;
|
|
|
|
|
+ this.redisStringObj = redisStringObj;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void putObject(String objectName, File file, String contentType, String sha256sum) throws Exception {
|
|
public void putObject(String objectName, File file, String contentType, String sha256sum) throws Exception {
|
|
@@ -144,7 +148,15 @@ public class ObjectBasicService {
|
|
|
|
|
|
|
|
public void getObject(String objectName) throws IOException {
|
|
public void getObject(String objectName) throws IOException {
|
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
|
- FileMeta fileMeta = fileMetaMapper.findByObjectName(objectName);
|
|
|
|
|
|
|
+ Object object = redisStringObj.get(objectName);
|
|
|
|
|
+ FileMeta fileMeta;
|
|
|
|
|
+ if (object != null) {
|
|
|
|
|
+ fileMeta = (FileMeta) object;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fileMeta = fileMetaMapper.findByObjectName(objectName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // FileMeta fileMeta = fileMetaMapper.findByObjectName(objectName);
|
|
|
if (fileMeta == null) {
|
|
if (fileMeta == null) {
|
|
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
|
|
|
|