From 89136d15510edaa6050fbca3bd2e53cec737c11c Mon Sep 17 00:00:00 2001 From: Markus Sackmann Date: Tue, 14 Nov 2017 10:32:45 +0100 Subject: [PATCH] Move getResource under exception handling --- build.number | 4 +-- .../io/cache/redis/RedisConnection.java | 30 +++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/build.number b/build.number index 06ec286..6626d9d 100644 --- a/build.number +++ b/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Fri Oct 27 15:54:33 CEST 2017 -build.number=17 +#Thu Nov 09 12:39:54 CET 2017 +build.number=28 diff --git a/source/java/src/lucee/extension/io/cache/redis/RedisConnection.java b/source/java/src/lucee/extension/io/cache/redis/RedisConnection.java index d384501..62ef98c 100644 --- a/source/java/src/lucee/extension/io/cache/redis/RedisConnection.java +++ b/source/java/src/lucee/extension/io/cache/redis/RedisConnection.java @@ -35,11 +35,31 @@ public static JedisPool init(String cacheName, Struct arguments){ Integer port = caster.toInteger(hosts.split(":")[1]); - JedisPoolConfig config = new JedisPoolConfig(); - config.setTestOnBorrow(true); - // config.setTestOnReturn(true); - - instance.put(cacheName, new JedisPool(config, host, port)); + Integer setMaxTotal = caster.toInteger(arguments.get("setMaxTotal"),128); + Integer setMaxIdle = caster.toInteger(arguments.get("namespace"),128); + Integer setMinIdle = caster.toInteger(arguments.get("namespace"),16); + Integer setMinEvictableIdleTimeMillis = caster.toInteger(arguments.get("setMinEvictableIdleTimeMillis"),60000); + Integer setTimeBetweenEvictionRunsMillis = caster.toInteger(arguments.get("setTimeBetweenEvictionRunsMillis"),30000); + Integer setNumTestsPerEvictionRun = caster.toInteger(arguments.get("setNumTestsPerEvictionRun"),3); + + Boolean setTestOnBorrow = caster.toBoolean(arguments.get("setTestOnBorrow"),true); + Boolean setTestOnReturn = caster.toBoolean(arguments.get("setTestOnReturn"),true); + Boolean setTestWhileIdle = caster.toBoolean(arguments.get("setTestWhileIdle"),true); + Boolean setBlockWhenExhausted = caster.toBoolean(arguments.get("setBlockWhenExhausted"),true); + + final JedisPoolConfig poolConfig = new JedisPoolConfig(); + poolConfig.setMaxTotal(setMaxTotal); + poolConfig.setMaxIdle(setMaxIdle); + poolConfig.setMinIdle(setMinIdle); + poolConfig.setTestOnBorrow(setTestOnBorrow); + poolConfig.setTestOnReturn(setTestOnReturn); + poolConfig.setTestWhileIdle(setTestWhileIdle); + poolConfig.setMinEvictableIdleTimeMillis(setMinEvictableIdleTimeMillis); + poolConfig.setTimeBetweenEvictionRunsMillis(setTimeBetweenEvictionRunsMillis); + poolConfig.setNumTestsPerEvictionRun(setNumTestsPerEvictionRun); + poolConfig.setBlockWhenExhausted(setBlockWhenExhausted); + + instance.put(cacheName, new JedisPool(poolConfig, host, port)); } catch (PageException e) { e.printStackTrace();