// Path: src/main/java/io/mycat/jcache/net/conn/handler/redis/strings/RedisGetCommandHandler.java
// public class RedisGetCommandHandler extends AbstractRedisComandHandler {
// 
//     private static final Logger logger = LoggerFactory.getLogger(RedisGetCommandHandler.class);
// 
//     @Override
//     public void handle(Connection conn,RedisMessage message) {
//         logger.debug("handle get command....");
//         String[] cmdParams = message.cmdParams();
//         String params = cmdParams[1];
// 
//         ConcurrentMap<String, Object> strStorage = RedisStorage.getStringStorage();
//         if(!strStorage.containsKey(params)){
//             message.addNilReply(message);
//             writeResponseToClient(conn,message);
//             return;
//         }
//         String value = (String)strStorage.get(params);
//         if(value==null || value.equals("")){
//             message.addNilReply(message);
//         }else {
//             message.replay("$" + value.length() + "\r\n" + value + "\r\n");
//         }
//         writeResponseToClient(conn,message);
//     }
// }
// 
// Path: src/main/java/io/mycat/jcache/net/conn/handler/redis/strings/RedisSetCommandHandler.java
// public class RedisSetCommandHandler extends AbstractRedisComandHandler {
// 
//     private static final Logger logger = LoggerFactory.getLogger(RedisGetCommandHandler.class);
// 
//     @Override
//     public void handle(Connection conn, RedisMessage message) {
//         logger.debug("set command handler....");
//         String key = message.cmdParams()[1];
//         Object value = message.cmdParams()[2];
// 
//         RedisStorage.getStringStorage().put(key,value);
// 
//         message.replay("OK\r\n");
//         writeResponseToClient(conn,message);
//     }
// }


import io.mycat.jcache.net.conn.handler.redis.strings.RedisGetCommandHandler;
import io.mycat.jcache.net.conn.handler.redis.strings.RedisSetCommandHandler;
package io.mycat.jcache.net.conn.handler;


/**
 * command handler 工厂类
 * @author yangll
 * @create 2017-07-18 21:08
 */

public final class RedisCommandHandlerFactory {

    /**
     * 根据不同的cmd，返回不同的命令处理器
     * @param cmd
     * @return
     */
    public static RedisCommandHandler getHandler(String cmd){
        switch (cmd){
            case "get":
// Path: src/main/java/io/mycat/jcache/net/conn/handler/redis/strings/RedisGetCommandHandler.java
// public class RedisGetCommandHandler extends AbstractRedisComandHandler {
// 
//     private static final Logger logger = LoggerFactory.getLogger(RedisGetCommandHandler.class);
// 
//     @Override
//     public void handle(Connection conn,RedisMessage message) {
//         logger.debug("handle get command....");
//         String[] cmdParams = message.cmdParams();
//         String params = cmdParams[1];
// 
//         ConcurrentMap<String, Object> strStorage = RedisStorage.getStringStorage();
//         if(!strStorage.containsKey(params)){
//             message.addNilReply(message);
//             writeResponseToClient(conn,message);
//             return;
//         }
//         String value = (String)strStorage.get(params);
//         if(value==null || value.equals("")){
//             message.addNilReply(message);
//         }else {
//             message.replay("$" + value.length() + "\r\n" + value + "\r\n");
//         }
//         writeResponseToClient(conn,message);
//     }
// }
// 
// Path: src/main/java/io/mycat/jcache/net/conn/handler/redis/strings/RedisSetCommandHandler.java
// public class RedisSetCommandHandler extends AbstractRedisComandHandler {
// 
//     private static final Logger logger = LoggerFactory.getLogger(RedisGetCommandHandler.class);
// 
//     @Override
//     public void handle(Connection conn, RedisMessage message) {
//         logger.debug("set command handler....");
//         String key = message.cmdParams()[1];
//         Object value = message.cmdParams()[2];
// 
//         RedisStorage.getStringStorage().put(key,value);
// 
//         message.replay("OK\r\n");
//         writeResponseToClient(conn,message);
//     }
// }


// Path: src/main/java/io/mycat/jcache/net/conn/handler/RedisCommandHandlerFactory.java
import io.mycat.jcache.net.conn.handler.redis.strings.RedisGetCommandHandler;
import io.mycat.jcache.net.conn.handler.redis.strings.RedisSetCommandHandler;

package io.mycat.jcache.net.conn.handler;


/**
 * command handler 工厂类
 * @author yangll
 * @create 2017-07-18 21:08
 */

public final class RedisCommandHandlerFactory {

    /**
     * 根据不同的cmd，返回不同的命令处理器
     * @param cmd
     * @return
     */
    public static RedisCommandHandler getHandler(String cmd){
        switch (cmd){
            case "get":
                return  new RedisGetCommandHandler();