mybatis / ehcache-cache Goto Github PK
View Code? Open in Web Editor NEWMyBatis EhCache adapter
Home Page: http://mybatis.github.io/ehcache-cache
License: Apache License 2.0
MyBatis EhCache adapter
Home Page: http://mybatis.github.io/ehcache-cache
License: Apache License 2.0
See the details here:
mybatis/mybatis-3#116
Can load config form other place?
How to use a existed ehcacheManager?
<bean id="ehcacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:my-ehcache.xml" />
</bean>
new ehcache version :
// https://mvnrepository.com/artifact/net.sf.ehcache/ehcache-core
compile group: 'net.sf.ehcache', name: 'ehcache-core', version: '2.6.11'
在ehcache.xml配置了默认的缓存信息,时间300s
在mapper.xml配置过期时间3s,测试结果,还是300s有效果
使用springboot 框架
No need to lock accesses to cache. EhCache provides locking by default.
Hello,
Is this library is supported with ehcache v3.x, don't found the information on web page : http://www.mybatis.org/ehcache-cache/
Best regards
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/ci.yaml
actions/checkout v4
actions/setup-java v4
.github/workflows/codeql.yml
actions/checkout v4
github/codeql-action v3
github/codeql-action v3
github/codeql-action v3
.github/workflows/coveralls.yaml
actions/checkout v4
actions/setup-java v4
.github/workflows/site.yaml
actions/checkout v4
actions/setup-java v4
JamesIves/github-pages-deploy-action v4.6.0
.github/workflows/sonar.yaml
actions/checkout v4
actions/setup-java v4
.github/workflows/sonatype.yaml
actions/checkout v4
actions/setup-java v4
pom.xml
org.mybatis:mybatis-parent 43
org.mybatis:mybatis 3.5.16
net.sf.ehcache:ehcache 2.10.9.2
org.junit.jupiter:junit-jupiter-engine 5.10.2
org.slf4j:slf4j-simple 2.0.13
.mvn/wrapper/maven-wrapper.properties
maven 3.9.6
maven-wrapper 3.3.1
MyBatis version 3.2.0
in putObject param value is ArrayList and you don't check if is it empty and write to cache, when next time call getObject it returns empty list but in database row has already
and another forks with cache the same situation
example:
SqlSession sqlSession = sqlSessionFactory.openSession();
....
try{
Types t=typesMapper.getTypeByName("cool");
if(t==null){
typesMapper.create('cool');
}
}
finally{
sqlSession .close();
}
//put to cache empty list
......
openSession();
Types t=typesMapper.getTypeByName("cool");//get from cache empty list but object was created
Hi anybody,
I want to integrate ehcache into spring, mybatis, but I did't find any useful materials on mybatis site. Does anyone have experience on this?
Best Regard!
@emacarron Lack of a better way to contact you! I've had an open pull request which has evolved over the last few months and follows all the others I've been doing. hazelcast-cache. Can you take a look at it?
First I want to thank you for that library, seamless integration to ehcache.
As the documentation suggest we can use EhBlockingCache, I tried to use since I have use case where I have concurrent write to same entry.
Except it fails for every request with NPE.
Looking a the code, it seems that
this.cache
is never initialized in EhBlockingCache
I'm revisiting the use of mybatis/ehcache-cache in a web application. I have setup a few MyBatis mappers to use org.mybatis.caches.ehcache.EhcacheCache and I have them configured via a central ehcache.xml file with individual cache managers () configured for each mapper.
Using a profiler and viewing MBeans for net.sf.ehcache, I can see the mappers being setup according to my configuration, what I don't see is a respect for the maxBytesLocalDisk setting I provide. In other words, as I query my website, and run the disk usage command on my file system, looking at the mybatis cache path, the disk usage seems to grow without limit.
I've tried both setting a global maxBytesLocal disk as well as a maxBytesLocalDisk at an individual cache manager level. Below is my latest setup.
Snippet from mapper.xml file:
<mapper namespace="org.cbioportal.persistence.mybatis.SampleMapper"> <cache readOnly="true" type="org.mybatis.caches.ehcache.EhcacheCache"/>
...
</mapper>
Snippet from ehcache.xml:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false" monitoring="autodetect" maxBytesLocalDisk="${mybatis.cache.maxBytesLocalDisk}" dynamicConfig="true" name="myapp-ehcache">
<cache name="org.cbioportal.persistence.mybatis.SampleMapper" statistics="${mybatis.cache.statistics}" maxEntriesLocalHeap="${mybatis.cache.SampleMapper.entrysize}">
<persistence strategy="localTempSwap"/>
</cache>
</ehcache>
For testing I currently have mybatis.cache.maxBytesLocalDisk set to 10M, but I'm already at 145M after a few queries:
du -sh ~/local/apache-tomcat/ehcache/org%002ecbioportal%002epersistence%002emybatis%002e%0053ample%004dapper.data
145M /Users/grossb1/local/apache-tomcat/ehcache/org%002ecbioportal%002epersistence%002emybatis%002e%0053ample%004dapper.data
This latest configuration sets a global maxBytesLocalDisk (within ehcache element), but I've tried to set them at the mapper/cache manager level (within cache element) with the same result.
Any ideas what I'm doing wrong?
Thanks for your time and attention to this matter - and thanks for the library, very useful in my application!
Is there anyway to integrate the Ehcache monitor within the mapper XML file? The only documentation I find on setting up the monitor is through a separate ehcache.xml. If thats the case, can you have an ehcache.xml file to specify the monitor settings and have cache elements defined in the mapper xml files simultaneously?
Thanks!
duplicated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.