1. 程式人生 > 其它 >leetcode 283. Move Zeroes(python)

leetcode 283. Move Zeroes(python)

package cn.jztd.redis.util;

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

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public  class JediPoolUtils {
    private static JedisPool jedisPool;
    
//靜態程式碼塊讀取配置檔案 static { //讀取配置檔案 InputStream inp = JediPoolUtils.class.getClassLoader().getResourceAsStream("jedis.properties"); //關聯檔案 Properties pro=new Properties(); try { pro.load(inp); } catch (IOException e) { e.printStackTrace(); }
//讀取配置檔案設定到JedisPoolConfig裡 JedisPoolConfig jedis=new JedisPoolConfig(); jedis.setMaxIdle(Integer.parseInt(pro.getProperty("maxIdle"))); jedis.setMaxTotal(Integer.parseInt(pro.getProperty("maxTotal"))); //初始化JedisPool jedisPool=new JedisPool(jedis,pro.getProperty("host"), Integer.parseInt(pro.getProperty("port"))); }
public static Jedis getJed(){ return jedisPool.getResource(); } }

配置檔案

host=127.0.0.1
port=6379
maxTotal=50
maxIdle=10