jedis配置
2024-10-19 00:19:25
public interface IJedisClientFactory { Jedis getJedis(); }
JedisClientFactoryImpl.java
@Service public class JedisClientFactoryImpl implements IJedisClientFactory { private final JedisPool pool; private final String password; public JedisClientFactoryImpl() { JedisPoolConfig config = new JedisPoolConfig(); config.setBlockWhenExhausted(false); config.setMaxTotal(150); config.setMaxIdle(150); config.setMinIdle(100); config.setMaxWaitMillis(2000); config.setMinEvictableIdleTimeMillis(300000); config.setTestOnBorrow(false); InputStream inputStream = this.getClass().getResourceAsStream("/jedis.properties"); Properties properties = new Properties(); try { properties.load(inputStream); } catch (IOException e) { e.printStackTrace(); } String url = (String)properties.get("url"); int port = Integer.parseInt((String)properties.get("port")); int timeout = Integer.parseInt((String)properties.get("timeout")); password = (String)properties.get("password"); pool = new JedisPool(config, url,port,timeout); } @Override public synchronized Jedis getJedis() { Jedis resource = pool.getResource(); resource.auth(password); return resource; } @PreDestroy public void closePool(){ pool.destroy(); } }
最新文章
- javascript中针对float的ceil及floor
- Codeforces CF#628 Education 8 E. Zbazi in Zeydabad
- eclipse js卡顿
- python常用代码
- div图片垂直居中 如何使div中图片垂直居中
- python爬虫下载youtube单个视频
- 如何实现在O(n)时间内排序,并且空间复杂度为O(1)
- No orientation specified, and the default is
- Spring Boot 系列教程12-EasyPoi导出Excel下载
- javascript 计算两个日期的差值
- ES6的generator函数
- JQuery其他常用函数
- BAT面试官告诉你如何回答你的职业规划
- Nagios故障 CHECK_NRPE: Socket timeout after 10 seconds.
- SpringCloud第一弹(入门)
- Win10更新搜狗输入法后重启输入密码蓝屏
- BZOJ 2457 - 双端队列 - [思维题]
- META标签之关键词、网页描述设置帮助SEO网站优化(转)
- kt 集合
- Messages: java.lang.NullPointerExceptionFile: org/apache/jsp/test_jsp.javaLine number: 23