pull/4/head
zhouyu 9 months ago
parent eafc9437f9
commit 7d27139b34

@ -14,14 +14,28 @@ import javax.annotation.PostConstruct;
* @CONTACT 317758022@qq.com
* @DESC redisredishash
*/
// 使用@Component注解将该类标记为Spring容器中的一个组件使得Spring能够对其进行管理方便进行依赖注入等相关操作。
@Component
// 使用lombok的@Slf4j注解用于自动生成日志相关的代码这样在类中就可以方便地记录各种操作的日志信息便于后续的调试以及问题排查。
@Slf4j
public class JedisPoolWrapper {
// 通过Spring的依赖注入机制使用@Autowired注解自动注入Parameters类型的实例
// 从命名来看Parameters类应该是用于存放各种配置参数的此处可能是包含了Redis相关的配置参数比如连接池最大连接数等用于后续初始化Jedis连接池。
@Autowired
private Parameters parameters;
// 声明一个JedisPool类型的私有变量用于存放Jedis连接池的实例初始值设为null会在后续的初始化方法中进行实例化赋值。
private JedisPool jedisPool = null;
/**
* 使@PostConstructJedis
*
* 1. JedisPoolConfigJedis
* 2. parametersparameters.getRedisMaxTotal()JedisPoolConfig
* 3. 使JedisPoolConfigparametersRedis2000"xxx"JedisPooljedisPool
* 4. log.error便log.info
*/
@PostConstruct
public void init(){
try {
@ -36,7 +50,10 @@ public class JedisPoolWrapper {
}
}
/**
* JedisPoolJedisJedisRedis
*/
public JedisPool getJedisPool() {
return jedisPool;
}
}
}
Loading…
Cancel
Save