@Test public void test5() throws Exception { Map<String, String> map = new HashMap<String, String>() { { put("TEST", "PASTVAL"); } }; Map<String, Long> map2 = new HashMap<>(); byte[][] args = new byte[3][]; args[0] = new byte[]{(byte) Command.SET.ordinal()}; args[1] = "TEST".getBytes(); args[2] = "VALUE".getBytes(); SetCommand s = new SetCommand(map, map2); ReplyMessage reply = s.run(3, args); assertEquals(StringMessage.OkMessage.message(), reply.message()); }
@Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 3) { return ErrorMessage.WrongArgcMessage; } String key = new String(argv[1], Protocol.KEYCAFE_CHARSET); String val = new String(argv[2], Protocol.KEYCAFE_CHARSET); kvMap.put(key, val); logger.info("set key: {} - result: {}", key, val); tMap.put(key, System.currentTimeMillis()); return StringMessage.OkMessage; }
SetCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 3) { return ErrorMessage.WrongArgcMessage; } String key = new String(argv[1], Protocol.KEYCAFE_CHARSET); String val = new String(argv[2], Protocol.KEYCAFE_CHARSET); kvMap.put(key, val); logger.info("set key: {} - result: {}", key, val); tMap.put(key, System.currentTimeMillis()); return StringMessage.OkMessage; } }
SetCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 3) { return ErrorMessage.WrongArgcMessage; } String key = new String(argv[1], Protocol.KEYCAFE_CHARSET); String val = new String(argv[2], Protocol.KEYCAFE_CHARSET); kvMap.put(key, val); logger.info("set key: {} - result: {}", key, val); tMap.put(key, System.currentTimeMillis()); return StringMessage.OkMessage; } SetCommand(Map<String, String> kvMap, Map<String, Long> tMap); }
SetCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 3) { return ErrorMessage.WrongArgcMessage; } String key = new String(argv[1], Protocol.KEYCAFE_CHARSET); String val = new String(argv[2], Protocol.KEYCAFE_CHARSET); kvMap.put(key, val); logger.info("set key: {} - result: {}", key, val); tMap.put(key, System.currentTimeMillis()); return StringMessage.OkMessage; } SetCommand(Map<String, String> kvMap, Map<String, Long> tMap); @Override ReplyMessage run(int argc, byte[][] argv); @Override int keyIndex(); }
SetCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 3) { return ErrorMessage.WrongArgcMessage; } String key = new String(argv[1], Protocol.KEYCAFE_CHARSET); String val = new String(argv[2], Protocol.KEYCAFE_CHARSET); kvMap.put(key, val); logger.info("set key: {} - result: {}", key, val); tMap.put(key, System.currentTimeMillis()); return StringMessage.OkMessage; } SetCommand(Map<String, String> kvMap, Map<String, Long> tMap); @Override ReplyMessage run(int argc, byte[][] argv); @Override int keyIndex();  }