flowable交流群:633168411

flowable自定义流程定义缓存

场景:当大量的流程定义出现的时候,我们势必会不停的查询流程定义,然而流程定义之后和版本对应很少发生变化,这个时候,我们可以把这个流程定义缓存起来,以提高系统性能。

这里我采用的是本地缓存

1、定义流程定义缓存对象


@Component
public class CustomDeploymentCache implements DeploymentCache<ProcessDefinitionCacheEntry> {
// @Autowired
// private CacheManager cacheManager;
public static final Map<String,ProcessDefinitionCacheEntry> caches = new ConcurrentHashMap<>();

@Override
public ProcessDefinitionCacheEntry get(String s) {
return caches.get(s);
}

@Override
public boolean contains(String s) {
boolean flag = false;
if (caches.get(s) != null) {
flag = true;
}
return flag;
}

@Override
public void add(String s, ProcessDefinitionCacheEntry processDefinitionCacheEntry) {
caches.put(s, processDefinitionCacheEntry);
}

@Override
public void remove(String s) {
caches.remove(s);
}

@Override
public void clear() {
caches.clear();
}
}
 

2、配置缓存

//设置缓存
        configure.setProcessDefinitionCache(customDeploymentCache);

 

posted @ 2019-09-06 14:54  小学生05101  阅读(2435)  评论(0编辑  收藏  举报
flowable交流群:633168411