Destiny.Lin
5 months ago
4 changed files with 68 additions and 3 deletions
@ -0,0 +1,56 @@
|
||||
package com.fr.design.cache; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 设计器缓存管理 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/8/11 |
||||
*/ |
||||
public class DesignCacheManager { |
||||
|
||||
public static ThreadLocal<Map<String, TableData>> cacheTableData = new ThreadLocal<>(); |
||||
|
||||
/** |
||||
* 处理任务(使用数据集缓存) |
||||
*/ |
||||
public static void processByCacheTableData(Task task) { |
||||
try { |
||||
cacheTableData.set(TableDataFactory.getTableDatas()); |
||||
task.process(); |
||||
} finally { |
||||
cacheTableData.remove(); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 是否使用数据集的缓存 |
||||
*/ |
||||
public static boolean useDataCache() { |
||||
return cacheTableData.get() != null; |
||||
} |
||||
|
||||
public static ThreadLocal<Map<String, TableData>> getCacheTableData() { |
||||
return cacheTableData; |
||||
} |
||||
|
||||
public static void setCacheTableData(ThreadLocal<Map<String, TableData>> cacheTableData) { |
||||
DesignCacheManager.cacheTableData = cacheTableData; |
||||
} |
||||
|
||||
/** |
||||
* 任务 |
||||
*/ |
||||
public interface Task { |
||||
/** |
||||
* 处理 |
||||
*/ |
||||
void process(); |
||||
} |
||||
} |
Loading…
Reference in new issue