Commit 22a39522 by amir

ver 1.1.1 taking redis host port from env

parent 7227f61b
group 'com.ipgallery.common' group 'com.ipgallery.common'
version '1.1.0' version '1.1.1'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
...@@ -19,7 +19,6 @@ dependencies { ...@@ -19,7 +19,6 @@ dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.3' compile 'com.fasterxml.jackson.core:jackson-databind:2.2.3'
compile 'com.googlecode.libphonenumber:libphonenumber:5.8' compile 'com.googlecode.libphonenumber:libphonenumber:5.8'
compile group: 'com.google.gdata', name: 'core', version: '1.47.1' compile group: 'com.google.gdata', name: 'core', version: '1.47.1'
// compile 'com.google.gdata:gdata-core-1.0:1.36.0'
compile 'org.apache.httpcomponents:httpclient:4.1' compile 'org.apache.httpcomponents:httpclient:4.1'
compile 'org.apache.httpcomponents:httpmime:4.1' compile 'org.apache.httpcomponents:httpmime:4.1'
compile 'javax.ws.rs:javax.ws.rs-api:2.0' compile 'javax.ws.rs:javax.ws.rs-api:2.0'
......
...@@ -11,10 +11,14 @@ public class RedisCacheClient implements CacheClient ...@@ -11,10 +11,14 @@ public class RedisCacheClient implements CacheClient
private static int CACHE_EXPIRATION_TIMEOUT; private static int CACHE_EXPIRATION_TIMEOUT;
public static int INITIAL_CAPACITY = 64; public static int INITIAL_CAPACITY = 64;
private static int DEFAULT_REDIS_DATABASE_INDEX; private static int DEFAULT_REDIS_DATABASE_INDEX;
private static final String REDIS_PORT;
private static final String REDIS_IP_ADDRESS;
static { static {
CACHE_EXPIRATION_TIMEOUT = Integer.valueOf(System.getProperty("cache.expiration.timeout","300")).intValue(); CACHE_EXPIRATION_TIMEOUT = Integer.valueOf(System.getProperty("cache.expiration.timeout","300")).intValue();
DEFAULT_REDIS_DATABASE_INDEX = Integer.valueOf(System.getProperty("cache.redis.database.index.timeout","1")).intValue(); DEFAULT_REDIS_DATABASE_INDEX = Integer.valueOf(System.getProperty("cache.redis.database.index.timeout","1")).intValue();
REDIS_IP_ADDRESS = System.getProperty("redis.host","localhost");
REDIS_PORT = System.getProperty("redis.port","6379");
} }
private JedisPool jedisPool = null; private JedisPool jedisPool = null;
...@@ -22,22 +26,22 @@ public class RedisCacheClient implements CacheClient ...@@ -22,22 +26,22 @@ public class RedisCacheClient implements CacheClient
public RedisCacheClient() public RedisCacheClient()
{ {
initPool("localhost"); initPool(REDIS_IP_ADDRESS,Integer.valueOf(REDIS_PORT).intValue());
} }
public RedisCacheClient(String host) public RedisCacheClient(String host)
{ {
initPool(host); initPool(host, Integer.valueOf(REDIS_PORT));
} }
private void initPool(String host) { private void initPool(String host, int port) {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(200); jedisPoolConfig.setMaxTotal(200);
jedisPoolConfig.setMaxIdle(100); jedisPoolConfig.setMaxIdle(100);
jedisPoolConfig.setMinIdle(50); jedisPoolConfig.setMinIdle(50);
jedisPoolConfig.setTestWhileIdle(true); jedisPoolConfig.setTestWhileIdle(true);
jedisPoolConfig.setMaxWaitMillis(500); jedisPoolConfig.setMaxWaitMillis(500);
jedisPool = new JedisPool(jedisPoolConfig, host); jedisPool = new JedisPool(jedisPoolConfig, host,port);
} }
private Jedis getJedis() private Jedis getJedis()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment