MyBatis-Redis extension Redis support for MyBatis Cache.
mybatis / redis-cache Goto Github PK
View Code? Open in Web Editor NEWMyBatis Redis Cache adapter
Home Page: http://mybatis.github.io/redis-cache
License: Apache License 2.0
MyBatis Redis Cache adapter
Home Page: http://mybatis.github.io/redis-cache
License: Apache License 2.0
MyBatis-Redis extension Redis support for MyBatis Cache.
When i use redis-cache in my project ,it throws exception,as you see,"Could not get a resource from the pool".
this is more infomation
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(DualStackPlainSocketImpl.java)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at redis.clients.jedis.Connection.connect(Connection.java:144)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:71)
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1783)
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:65)
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:819)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:429)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360)
at redis.clients.util.Pool.getResource(Pool.java:40)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:84)
Hello
I found that in redis.properties the property names must be host,port,password, otherwise mybatis will config the redis with the default value .
For example, below is my redis.properties
redis.host=192.168.1.10
redis.port=6379
redis.password=
redis.maxIdle=100
redis.maxActive=300
redis.maxWait=1000
redis.testOnBorrow=true
redis.timeout=100000
MyBatis cannot find host,port,password (and ingore the properties maxIdle,maxActive...),but set the host with default value localhost
and I had got connection refused error.
I must define
host=192.168.1.10
port=6379
password=
In my project, there was also a property password in jdbc.properties, so...I must change the jdbc property name and modify dbcp config in spring config file carefully.
This problem confused me quite a time, it seems the redis server was not setup corrected at first...finally I found the truth above !
I wrote this issue for hoping others to avoid the same problem!
Several data were obtained from the database, but only one of them was obtained from redis. I am not familiar with the redis, I do not know the problem is the configuration in the redis or redis-cache. Have you ever encountered such a problem?
The src of the version 1.0.0-beta2 from maven are different from those from github.
especially, the constructor of RedisCache, as follow:
pool = new JedisPool(redisConfig, redisConfig.getHost(), redisConfig.getPort(),
redisConfig.getConnectionTimeout(), redisConfig.getSoTimeout(), redisConfig.getPassword(),
redisConfig.getDatabase(), redisConfig.getClientName());
which is not avaliable constructor of JedisPool of version 2.9.0...
or, is there anything i misunderstood?
I use alibaba datasource druid ,when I deal database update,cache not update
trying to use redis via maven,
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-redis</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
got this error,
Could not find artifact org.mybatis.caches:mybatis-redis:jar:1.0.0-SNAPSHOT -> [Help 1]
im using this example,
http://mybatis.github.io/redis-cache/index.html
do you have any idea what maven repositories should i use?
thank you.
The parseConfiguration method of the RedisConfigurationBuilder class, InputStream is dead, which means that can not be used in the maven project multi-environment configuration, such as the development environment, production environment, because this class is final type, so can modify from the classpath.
Is this framework support SQL's join?
How to Adaptation environment? like this
dev read redis-dev.properties
test read redis-test.properties
prod read redis-prod.properties
Or, I'm use spring boot, use the profiles, how to read environment in org.springframework.boot.autoconfigure.data.redis.RedisProperties
?
And, If use the new jedis version(2.9.0)
pool = new JedisPool(...)
was error...
Can I support setting a default expiration time for Key when caching?
Last release in Maven central repository was 28-Dec-2015.
How can I contribute to make it move forward?
if redis server down,i want direct query from db and not throw exception, how can i config?
I use flushInterval like this:
<mapper namespace="cn.com.xxxxx.dao.mapper.TestMapper"> <cache type="org.mybatis.caches.redis.RedisCache" flushInterval="2000"/> ...
after more than 2 seconds,I use this query again,but I just see information like this(in console):
org.apache.ibatis.cache.decorators.LoggingCache:62 - Cache Hit Ratio [cn.com.chengyisheng.dao.mapper.TestMapper]: 0.875
It means this query use cache result again.
why? How to use flushInterval
Hi there,
are there any updates on redis-cache? Anything needed to help out?
Last version is from 2015 and there have been many updates in Jedis and MyBatis.
Thank you for your time!
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
shogo82148/actions-setup-redis v1.34.0
.github/workflows/codeql.yml
actions/checkout v4
actions/setup-java v4
github/codeql-action v3
github/codeql-action v3
github/codeql-action v3
.github/workflows/coveralls.yaml
actions/checkout v4
actions/setup-java v4
supercharge/redis-github-action 1.8.0
.github/workflows/site.yaml
actions/checkout v4
actions/setup-java v4
JamesIves/github-pages-deploy-action v4
.github/workflows/sonar.yaml
actions/checkout v4
actions/setup-java v4
supercharge/redis-github-action 1.8.0
.github/workflows/sonatype.yaml
actions/checkout v4
actions/setup-java v4
supercharge/redis-github-action 1.8.0
pom.xml
org.mybatis:mybatis-parent 44
org.mybatis:mybatis 3.5.16
redis.clients:jedis 5.1.3
com.esotericsoftware.kryo:kryo5 5.5.0
org.junit.jupiter:junit-jupiter-engine 5.10.3
org.slf4j:slf4j-simple 2.0.13
.mvn/wrapper/maven-wrapper.properties
maven 3.9.8
maven-wrapper 3.3.2
没有针对redis集群的二级缓存实现么
Because I returned a DTO in the mapper file, some of the relevant insert, update in another file, so I need to manually refresh, or there are other ways?
I used AliCloudDB for Redis as my redis, and then occured an error, notice me that the command "client" was not supported.The i checked the source code, and found that, in the class RedisCache, when new a JedisPool, it set the clientName.But AliCloudDB for Redis does not support command "client" yet.
The solution is set the clientName to be empty in you redis config file.
see [here] (e7d4f07)
This was partially highlighted by moving property file into right location to caues issue to occur on travis. The new params in that commit are now commented out. I'm looking at a solution I wrote a long while back but have basically no experience here so any community help would be appreciated.
how to write spring configration,Conflict with spring-data-redis?
thank you
In class KryoSerializer
, I see the comments about SerializeUtil with Kryo, which is faster and more space consuming.
, but when I read this article https://www.shenyanchao.cn/blog/2019/02/13/redis-serializer/
, it looks like KryoSerializer
is faster and less space consuming.
article reference: https://www.shenyanchao.cn/blog/2019/02/13/redis-serializer/
What does this use caching policy?
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
### Cause: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.smarttrip.service.impl.StartDateService.selectByConditionMap(StartDateService.java:80)
at com.smarttrip.service.impl.StartDateServiceTest.test(StartDateServiceTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:606)
has anybody account this problem?when i use redis-cli to connect redis, the password i write in redis.properties is white.
host=xxxx.xxxx.xxxx.xxxx
port=6379
connectionTimeout=5000
soTimeout=5000
password=111111
database=0
clientName=develop
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.