gpt4 book ai didi

java - hibernatetemplate 清除ehcache?

转载 作者:行者123 更新时间:2023-12-02 00:53:45 27 4
gpt4 key购买 nike

<ehcache>
<cache name="query.ContactInfoList"
maxElementsInMemory="200"
eternal="true"
overflowToDisk="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
/>
</ehcache>

public List getContactInfoList(){
hibernateTemplate.setCacheQueries(true);
hibernateTemplate.setQueryCacheRegion("query.ContactInfoList");
List list = hibernateTemplate.find("from AdoContactInfo a where active = 1");
hibernateTemplate.setCacheQueries(false);
return list;
}

我可以知道如何在调用 hibernatetemplate saveupdate清除/刷新缓存 query.ContactInfoList

最佳答案

hibernateTemplate.getSessionFactory().evictQueries("query.ContactInfoList");

将清除该缓存区域。您无法手动刷新缓存的查询数据;一旦查询再次运行,缓存区域将被重新填充(如果启用)。

关于java - hibernatetemplate 清除ehcache?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1824523/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com