基础资料更新方式原创
金蝶云社区-cosmicstudio
cosmicstudio
10人赞赏了该文章 1,488次浏览 未经作者许可,禁止转载编辑于2022年04月07日 09:54:08

如下2种方式都是通过清空缓存,达到重新从DB加载数据的目的

 

a)         界面上直接调用基础资料相关操作(保存、提交、审核…)后会自动清除基础资料的缓存。上述操作都会触发dataEntities更新,执行如下子过程:

SaveServiceHelper.save(dataEntities)
->BusinessDataWriter.save(dataEntities)
->DataEntityCacheManager.removeByPrimaryKey() // 清空redis缓存
->DataEntityLocalCacheManager*.removeByDt() // 清空ehcache缓存

            

b)        调用接口清空缓存(不建议使用)

IDataEntityType  type = EntityMetadataCache.getDataEntityType(number);
DataEntityCacheManager cacheManager = new DataEntityCacheManager(type);
cacheManager.removeByPrimaryKey(Pks); // 这里会清空指定行redis & ehcache
或
cacheManager.removeByDt(); //清除所有记录缓存

 

c)         设计器保存或rebuild表单


d)       清除基础资料缓存

//清除基础资料缓存
kd.bos.servicehelper.BusinessDataServiceHelper.removeCache(DynamicObjectType type)

//清除基础资料缓存-操作表
DataEntityCacheManager cacheManager = new DataEntityCacheManager("table_name");
cacheManager.removeByPrimaryKey(metadata.getId());


赞 10