package org.crazycake.shiro;

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

import java.util.Set;

public class RedisManager extends JedisManager {

    private volatile JedisPool jedisPool = null;

    private void init() {
        synchronized (this) {
            if (jedisPool == null) {
                String[] hostAndPort = host.split(":");
                jedisPool = new JedisPool(new JedisPoolConfig(), hostAndPort[0], Integer.parseInt(hostAndPort[1]), timeout, password, database);
            }
        }
    }

    @Override
    protected Jedis getJedis() {
        if (jedisPool == null) {
            init();
        }
        return jedisPool.getResource();
    }

}

@@ -298,16 +298,38 @@
  = null;
+%0A    private int port;
 %0A%0A    pr
@@ -407,32 +407,121 @@
 Pool == null) %7B%0A
+                if(port == 0)%7B%0A                    // support host:port config style%0A    
                 
@@ -560,16 +560,20 @@
 t(%22:%22);%0A
+    
         
@@ -709,16 +709,169 @@
 abase);%0A
+                %7Delse%7B%0A                    jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout, password, database);%0A                %7D%0A%0A
         
@@ -1050,10 +1050,299 @@
 %0A    %7D%0A%0A
+    public JedisPool getJedisPool() %7B%0A        return jedisPool;%0A    %7D%0A%0A    public void setJedisPool(JedisPool jedisPool) %7B%0A        this.jedisPool = jedisPool;%0A    %7D%0A%0A    public int getPort() %7B%0A        return port;%0A    %7D%0A%0A    public void setPort(int port) %7B%0A        this.port = port;%0A    %7D%0A
 %7D%0A

support host:port (eg. host=127.0.0.1:6379) config style , keep old config sytle (eg. host=127.0.0.1 port=6379)