所有的流程定义都被缓存(在解析之后),以避免每次需要流程定义时从数据库获取,并且流程定义数据也不会发生变化。默认情况下,这个缓存没有限制。要限制流程定义缓存,请添加以下属性。
<property name="processDefinitionCacheLimit" value="10" />
您还可以注入自己的缓存实现。它必须实现org.activiti.engine.impl.persistence.deploy.DeploymentCache接口:
<property name="processDefinitionCache"> <bean class="org.activiti.MyCache" /> </property>
有一个类似的属性叫做knowledgeBaseCacheLimit和knowledgeBaseCache,用于配置规则缓存。只有在流程中使用规则任务时才需要这样做。