public void testMsetnx() throws ExecutionException, InterruptedException { Map<String, String> map = new HashMap<String, String>(); map.put("MAPNX_KEY1", "TES"); map.put("MAPNX_KEY2", "EST"); client.delete("MAPNX_KEY1", "MAPNX_KEY2"); long reply = client.msetObjectNx(map).get(); assertEquals(1, reply); client.delete("MAPNX_KEY1"); reply = client.msetObjectNx(map).get(); assertEquals(0, reply); }
public void testMget() throws ExecutionException, InterruptedException { Map<String, String> map = new HashMap<String, String>(); map.put("MAPMX_KEY1", "TES"); map.put("MAPMX_KEY2", "EST"); client.msetObjectNx(map).get(); List<String> result = (List<String>) client.mget(new String[] {"MAPMX_KEY1", "MAPMX_KEY2", "NON_EXIST"}).get(); assertEquals("TES", result.get(0)); assertEquals("EST", result.get(1)); assertEquals(null, result.get(2)); Map<String, Integer> map2 = new HashMap<String, Integer>(); map2.put("MAP_KEY1", 1); map2.put("MAP_KEY2", 2); String resultStr = client.msetInt(map2).get(); assertEquals("OK", resultStr); List<Integer> cached = client.mgetInt(new String[] {"MAP_KEY1", "MAP_KEY2"}).get(); assertEquals(2, cached.size()); assertEquals(1, cached.get(0).intValue()); assertEquals(2, cached.get(1).intValue()); }