package net.hawkengine.db.redis;

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

public class RedisManager {
    private static JedisPool jedisPool;

    public static void connect() {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        //poolConfig.setMaxTotal(20);
        poolConfig.setTestOnBorrow(true);
        jedisPool = new JedisPool(poolConfig, "192.168.99.100");
    }

    public static JedisPool getJedisPool() {
        return jedisPool;
    }

    public static void release() {
        jedisPool.destroy();
    }

    public static Jedis getJedis() {
        return jedisPool.getResource();
    }
}

@@ -38,33 +38,153 @@
 ort 
-redis.clients.jedis.Jedis
+net.hawkengine.core.ServerConfiguration;%0Aimport net.hawkengine.model.configuration.DatabaseConfig;%0Aimport net.hawkengine.model.enums.DatabaseType
 ;%0Aim
@@ -262,16 +262,51 @@
 lConfig;
+%0Aimport redis.embedded.RedisServer;
 %0A%0Apublic
@@ -350,64 +350,678 @@
 tic 
-JedisPool jedisPool;%0A%0A    public static void connect() %7B
+RedisServer redisEmbeddedDb;%0A    private static JedisPool jedisPool;%0A%0A    static JedisPool getJedisPool() %7B%0A        return jedisPool;%0A    %7D%0A%0A    public static void connect() %7B%0A        DatabaseConfig config = ServerConfiguration.getConfiguration().getDatabaseConfigs().get(DatabaseType.REDIS);%0A        String host = config.getHost();%0A        int port = config.getPort();%0A        String password = config.getPassword();%0A%0A        redisEmbeddedDb = RedisServer.builder().port(port).build();%0A%0A        boolean shouldUseEmbeddedDb = ServerConfiguration.getConfiguration().shouldUseEmbeddedDb();%0A        if (shouldUseEmbeddedDb) %7B%0A            redisEmbeddedDb.start();%0A        %7D%0A
 %0A   
@@ -1081,46 +1081,8 @@
 ();%0A
-        //poolConfig.setMaxTotal(20);%0A
     
@@ -1119,16 +1119,17 @@
 (true);%0A
+%0A
         
@@ -1170,219 +1170,110 @@
 ig, 
-%22192.168.99.100%22);%0A    %7D%0A%0A    public static JedisPool getJedisPool() %7B%0A        return jedisPool;%0A    %7D%0A%0A    public static void release() %7B%0A        jedisPool.destroy();
+host, port, 0, password);%0A    %7D%0A%0A    public static void disconnect() %7B
 %0A    
-%7D%0A%0A
     
-public static Jedis getJedis() %7B
+redisEmbeddedDb.stop();
 %0A   
@@ -1269,39 +1269,32 @@
 stop();%0A        
-return 
 jedisPool.getRes
@@ -1291,19 +1291,15 @@
 ool.
-getResource
+destroy
 ();%0A
@@ -1305,9 +1305,8 @@
 %0A    %7D%0A%7D
-%0A

revert redisManager