Files
zfile/src/main/java/im/zhaojun/common/service/FileCacheService.java
zhaojun1998 3ffdb4f1b2 清洁代码
2020-01-30 16:47:03 +08:00

39 lines
992 B
Java

package im.zhaojun.common.service;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhaojun
*/
@Service
public class FileCacheService {
@Resource
private SystemConfigService systemConfigService;
@Resource
@Lazy
private FileAsyncCacheService fileAsyncCacheService;
public void enableCache() {
systemConfigService.updateCacheEnableConfig(true);
AbstractFileService currentFileService = systemConfigService.getCurrentFileService();
currentFileService.openCacheAutoRefresh();
fileAsyncCacheService.cacheGlobalFile();
}
public void disableCache() throws Exception {
systemConfigService.updateCacheEnableConfig(false);
AbstractFileService currentFileService = systemConfigService.getCurrentFileService();
currentFileService.clearFileCache();
fileAsyncCacheService.resetCacheCount();
}
}