mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
39 lines
992 B
Java
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();
|
|
}
|
|
|
|
}
|