首页>代码>springboot整合jedis项目实例>/springboot-jedis/src/main/java/com/trq/springbootjedis/Util/JedisUtil.java
package com.trq.springbootjedis.Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
@Component
public class JedisUtil {
@Autowired
private JedisPool jedisPool;
/**
* 获取Jedis
*/
public Jedis getJedis() {
return jedisPool.getResource();
}
/**
* 关闭Jedis连接
*/
public void close(Jedis jedis) {
if(jedis != null) {
jedis.close();
}
}
// .....可以自行封装其他方法
}

最近下载
最近浏览