pull/4/head
zhouyu 9 months ago
parent 832b65469f
commit c6137bbb1d

@ -14,14 +14,26 @@ import javax.annotation.PostConstruct;
* @CONTACT 317758022@qq.com
* @DESC redisredishash
*/
// 使用Spring框架的@Component注解将该类标记为一个组件意味着Spring会对这个类进行管理使其能够参与到依赖注入等Spring容器的相关功能中方便在其他需要使用该类实例的地方通过自动注入等方式获取实例从而实现不同组件之间的协作。
@Component
// 使用lombok的@Slf4j注解用于自动生成日志相关的代码方便在类中记录各种操作相关的日志信息便于后续查看操作情况以及进行问题排查例如在初始化Jedis连接池时出现成功或失败的情况都可以通过日志清晰地记录下来方便了解系统状态以及定位问题。
@Slf4j
public class JedisPoolWrapper {
// 通过Spring的依赖注入机制使用@Autowired注解自动注入Parameters类型的实例Parameters类应该是用于存储系统相关配置参数的类在这里主要是期望从中获取与Redis连接池配置相关的参数例如最大连接数、最大空闲连接数等信息。
@Autowired
private Parameters parameters;
// 定义一个私有成员变量jedisPool用于存储Jedis连接池对象初始化为null后续会在初始化方法中根据配置参数来创建实际的Jedis连接池实例。
private JedisPool jedisPool = null;
/**
* 使Spring@PostConstruct
*
* JedisPoolConfigJedisPoolConfigJedis
* ParametersRedisJedisPoolConfigparameters.getRedisMaxTotal()config.setMaxTotalJedisPoolConfig
* 使JedisPoolConfigParametersRedisparameters.getRedisHost()parameters.getRedisPort()2000"xxx"JedisPooljedisPoolJedis
* log.errorredis便log.inforedis
*/
@PostConstruct
public void init(){
try {
@ -36,7 +48,12 @@ public class JedisPoolWrapper {
}
}
/**
* JedisPool
* JedisPoolJedisRedis
* initJedisPoolinitJedisPooljedisPoolnullnullnull
*/
public JedisPool getJedisPool() {
return jedisPool;
}
}
}
Loading…
Cancel
Save