RedisDBHandler implements IDBHandler { @Override public Map<Integer, byte[]> get(String key) { Map<Integer, byte[]> sequenceIdValue = new HashMap<Integer, byte[]>(); try { if (hasKey(key)) { byte[] serializedKey = serialize(key); Set<byte[]> byteSequencIds = redis.hkeys(serializedKey); for (byte[] bs : byteSequencIds) { sequenceIdValue.put((Integer) deserialize(bs), redis.hget(serializedKey, bs)); } } } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return sequenceIdValue; } RedisDBHandler(); synchronized Jedis getJedisConnection(); @Override String getDatabaseVendor(); byte[] serialize(Object obj); Object deserialize(byte[] bytes); @Override boolean hasKey(String key); @Override String put(String key, int sequenceId, byte[] value); @Override Map<Integer, byte[]> get(String key); @Override List<Integer> getSequenceIds(String key); @Override boolean update(String key, int sequenceId, byte[] value); @Override String store(byte[] value); @Override Map<Integer, byte[]> remove(String key);  }
@Test public void testGet() { String key = "prasanna"; Map<Integer, byte[]> mapGiven = new HashMap<Integer, byte[]>(); String obtainedKey = ""; try { mapGiven.put(0, serialize("data1")); mapGiven.put(2, serialize("data2")); obtainedKey = dbHandler.put(key, 0, serialize("data1")); assertEquals(key, obtainedKey); obtainedKey = dbHandler.put(key, 2, serialize("data2")); assertEquals(key, obtainedKey); Map<Integer, byte[]> map = dbHandler.get(key); for (Integer i : map.keySet()) { assertTrue(Arrays.equals(map.get(i), mapGiven.get(i))); } byte[] serializeValue = serialize("data3"); key = dbHandler.store(serializeValue); Map<Integer, byte[]> mapObtained = dbHandler.get(key); byte[] obtainedVal = mapObtained.get(0); assertTrue(Arrays.equals(serializeValue, obtainedVal)); } catch (IOException e) { e.printStackTrace(); } }