目录

  • flowable 清除流程本地缓存
    • 一、清除缓存 Cmd
    • 二、如何调用

flowable 清除流程本地缓存

flowable 或者 activity 修改流程图属性后,需要清除本地缓存,可以用以下方法来实现。

一、清除缓存 Cmd

package indi.tudan.modules.flowable.common.cmd;import indi.tudan.common.core.utils.StringUtils;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.common.engine.impl.persistence.deploy.DeploymentCache;
import org.flowable.engine.impl.persistence.deploy.DeploymentManager;
import org.flowable.engine.impl.persistence.deploy.ProcessDefinitionCacheEntry;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.repository.Deployment;import java.io.Serializable;/*** 清除流程缓存** @author wangtan* @date 2021-12-29 10:11:25* @since 1.0.0*/
public class DeploymentCacheCmd implements Command<Deployment>, Serializable {private static final long serialVersionUID = 1L;private final String definitionId;public DeploymentCacheCmd(String definitionId) {this.definitionId = definitionId;}@Overridepublic Deployment execute(CommandContext commandContext) {DeploymentManager deploymentManager = CommandContextUtil.getProcessEngineConfiguration().getDeploymentManager();DeploymentCache<ProcessDefinitionCacheEntry> deploymentCache = deploymentManager.getProcessDefinitionCache();if (StringUtils.isNotBlank(definitionId)) {// 清除指定缓存deploymentCache.remove(definitionId);} else {// 清除全部缓存deploymentCache.clear();}return null;}}dContextUtil.getProcessEngineConfiguration().getDeploymentManager();DeploymentCache<ProcessDefinitionCacheEntry> deploymentCache = deploymentManager.getProcessDefinitionCache();deploymentCache.remove(definitionId);return null;}}

其中 StringUtils 参考

package indi.tudan.common.core.utils;import java.util.regex.Matcher;
import java.util.regex.Pattern;/*** 字符串处理工具类** @author wangtan* @date 2019-10-27 13:43:20* @since 1.0.0*/
public class StringUtils {/*** Don't let anyone else instantiate this class*/private StringUtils() {}/*** 获取字符串** @param object 待处理数据* @return 处理后的字符串* @date 2019-10-26 17:31:49*/public static String getStr(Object object) {if (ObjectUtils.isNotNull(object)) {return String.valueOf(object);} else {return "";}}/*** 字符串是否为空** @param cs 字符串* @return boolean* @date 2019-10-26 17:31:14*/public static boolean isBlank(CharSequence cs) {int strLen;if (cs != null && (strLen = cs.length()) != 0) {for (int i = 0; i < strLen; ++i) {if (!Character.isWhitespace(cs.charAt(i))) {return false;}}}return true;}/*** 字符串是否不为空** @param cs 字符串* @return boolean* @date 2019-10-26 17:31:07*/public static boolean isNotBlank(CharSequence cs) {return !isBlank(cs);}/*** 若字符串为空,则返回 defaultString** @param string        字符串* @param defaultString 默认字符串* @return String* @author wangtan* @date 2019-09-06 13:53:42* @since 1.0.0*/public static String orElse(String string, String defaultString) {return isBlank(string) ? defaultString : string;}/*** 去除所有空白符** @param str 字符串* @return* @date 2020-07-21 19:55:39* @since 1.0.0*/public static String replaceBlank(String str) {String dest = null;if (str == null) {return dest;} else {Pattern p = Pattern.compile("\\s*|\t|\r|\n");Matcher m = p.matcher(str);dest = m.replaceAll("");return dest;}}}

二、如何调用

@Autowired
protected ManagementService managementService;// 清除某个流程的缓存
// 此处的 xxxxxxxxxxxx 只是示例,请根据实际传流程定义Id
managementService.executeCommand(new DeploymentCacheCmd("xxxxxxxxxxxx"));// 清除全部缓存
managementService.executeCommand(new DeploymentCacheCmd(""));

flowable 清除流程本地缓存相关推荐

  1. ehcache 清除缓存_如何设计一个本地缓存

    作者:ksfzhaohuihttp://my.oschina.net/OutOfMemory/blog/3133013 前言 最近在看Mybatis的源码,刚好看到缓存这一块,Mybatis提供了一级 ...

  2. 一键清除本地缓存的所有无用的docker镜像命令

    一键清除本地缓存的所有无用的docker镜像命令: docker images -q --filter "dangling=true" | xargs -t --no-run-if ...

  3. 谷歌浏览器怎么清除浏览器缓存以及本地缓存localstorage。

    清除浏览器缓存很容易首先点击右上角的小点打开设置选项,进入后找到打开清除浏览记录点进去,如下图: 然后把三个都勾上,清除数据,再打开你需要查看的网页就可以了,就不会存在历史缓存和记录了. 清除本地缓存 ...

  4. uni.app小程序登录页持久化存储和退出后清除本地缓存

    持久化存储 在store里面的user.js(自己创建的)中 export default {state: {status: false, //登录的状态,获取数据中status是1,登录成功时状态为 ...

  5. Glide清除缓存(清除内存缓存、本地缓存、清除所有缓存等)

    Glide使用讲解 https://blog.csdn.net/bzlj2912009596/article/details/81702367 Glide的图片缓存在/data/data/项目包名/c ...

  6. 同时存多个变量缓存 微信小程序_微信小程序 缓存(本地缓存、异步缓存、同步缓存)详解...

    微信小程序 缓存 关于本地缓存 1.wx.setStorage(wx.setStorageSync).wx.getStorage(wx.getStorageSync).wx.clearStorage( ...

  7. 本地缓存与分布式缓存

    更多内容,前往 IT-BLOG 一般而言,现在互联网应用(网站或App)的整体流程,可以概括如图所示,用户请求从界面(浏览器或App界面)到网络转发.应用服务再到存储(数据库或文件系统),然后返回到界 ...

  8. caffeine本地缓存的使用和详解

    在项目中我们经常使用缓存架构,来缓存我们的数据,比如redis.caffeine等.那么redis和caffeine有什么区别?作用又有哪些不同呢? caffeine本地缓存的使用和详解 caffei ...

  9. 微信小程序之缓存(本地缓存,同步缓存,异步缓存)

    关于本地缓存 1.wx.setStorage(wx.setStorageSync).wx.getStorage(wx.getStorageSync).wx.clearStorage(wx.clearS ...

  10. 微信小程序缓存(本地缓存,同步缓存,异步缓存)

    关于本地缓存 1.wx.setStorage(wx.setStorageSync).wx.getStorage(wx.getStorageSync).wx.clearStorage(wx.clearS ...

最新文章

  1. oracle元字符,oracle中正则表达式的基本元字符
  2. 51nod 1368:黑白棋 二分图最大匹配
  3. org.hibernate.HibernateException: connnection proxy not usable after transaction
  4. 人脸识别算法不可置疑?真相需要多重验证!
  5. Caffe训练过程:test_iter test_interval等概念
  6. zip伪加密破解方法
  7. 在sql server中用正则表达式替换html标签,SQL Server中利用正则表达式替换字符串
  8. 奶制品的生产lingo软件编辑
  9. SQL语句练习-入门篇
  10. 基于无人售货机商品售卖情况推荐商品
  11. 把JRuby Rails应用部署在Java应用服务器上
  12. 2019年又一位华为工程师倒下了
  13. PCB板材及叠层结构(转)
  14. mathematics中如何计算排列组合
  15. Fiddler Windows 汉化抓包工具
  16. 阿里云、腾讯云、UCloud、华为云云主机对比测试报告 | 技术
  17. C# TextBox 限制输入一点范围内的整数并有提示超过所限定范围的整数
  18. 无人机算什么?波士顿动力的“ 机器狗 ” 也要开始送快递了
  19. 使用scrapy框架爬boss直聘
  20. STM32F429第十八篇之基本定时器

热门文章

  1. 11位大牛与您共建数智升级路径
  2. 【图像去噪】基于matlab小波域双重局部维娜滤板图像去噪【含Matlab源码 1642期】
  3. 【语音去噪】基于matlab基本维纳滤波算法语音去噪【含Matlab源码 570期】
  4. 【卡号识别】基于matlab CNN银行卡数字识别【含Matlab源码 030期】
  5. pymysql.err.OperationalError: 1136, Column count doesn t match value count at row 1
  6. github下载的代码、怎么使用 python_Python学习20-补充内容之GitHub安装使用
  7. datagridview表中插入一行_excel表格技巧:Ctrl+T在超级表中的妙用
  8. flutter 判断是不是调试模式_Flutter之撸一个漂亮的登录界面的总结
  9. macbookpro升级后打不开eclipse_苹果更新MacBook Pro等蝶式键盘维修计划机型,包括最新2019款...
  10. 【挖坑系列】关于浏览器の缓存机制