Skip to content

Commit

Permalink
2018/11/29:redis
Browse files Browse the repository at this point in the history
  • Loading branch information
goodloving committed Nov 29, 2018
1 parent f5d827a commit fa04062
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 0 deletions.
40 changes: 40 additions & 0 deletions RedisUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package RedisConnection;

import java.util.ResourceBundle;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisUtils {
private static JedisPool pool = null;
private static int maxIdle;
private static int minIdle;
private static int maxTotal;
private static String url;
private static int port;


static {
//1.获取配置文件
ResourceBundle bundle = ResourceBundle.getBundle("redis");
maxIdle = Integer.parseInt(bundle.getString("maxIdle")) ;
minIdle = Integer.parseInt(bundle.getString("minIdle")) ;
maxTotal = Integer.parseInt(bundle.getString("maxTotal")) ;
url = bundle.getString("url");
port = Integer.parseInt(bundle.getString("port")) ;
//2.创建池子的配置
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxIdle(maxIdle); //最大闲置个数
config.setMinIdle(minIdle); //最小闲置个数
config.setMaxTotal(maxTotal); //最大连接个数

//3.创建连接池对象
pool = new JedisPool(config,url, port);
}

//实现jedis方法
public static Jedis getJedis() {
return pool.getResource();
}
}
Binary file modified java系列笔记.docx
Binary file not shown.
Binary file added jedis/commons-pool2-2.3.jar
Binary file not shown.
Binary file added jedis/jedis-2.7.0.jar
Binary file not shown.
Binary file added linux资料集合/SSHSecureShellClient-3.2.9.exe
Binary file not shown.
Binary file added linux资料集合/Xshell-6.0.0098.exe
Binary file not shown.
Binary file added redis-5.0.2.tar.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions redis.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
maxIdle=30
minIdle=10
maxTotal=100
url=10.6.228.4
port=6379

0 comments on commit fa04062

Please sign in to comment.