Mybtis使用 redis

Mybtis使用 redis 首先要引入 jar包会自动倒入jedis jar包

<!-- 引入mybatis-redis的连接 会自定倒入jedis -->
		<dependency>
		    <groupId>org.mybatis.caches</groupId>
		    <artifactId>mybatis-redis</artifactId>
		    <version>1.0.0-beta2</version>
		</dependency>

在xml中设置启用二级缓存cache

<mapper namespace="lesson_mybatis_redis.ActionSQL">
		 
		 <!-- eviction="FIFO"  //回收策略为先进先出
		 	type="org.mybatis.caches.redis.RedisCache" 用这个类处理缓存 
		 	其中有获取  redis   ip  端口   密码 的方法  
		  -->
		<cache eviction="FIFO" type="org.mybatis.caches.redis.RedisCache"/>
		<select id="query" resultType="lesson_mybatis_redis.StuBean"> 
				SELECT * FROM student  where id = #{0}
	 	</select>
</mapper>

添加资源文件到用于被读取redis.properties

host=192.168.0.16
port=6379
password=123456
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值