RedisDBHandler implements IDBHandler { @Override public boolean update(String key, int sequenceId, byte[] value) { boolean isUpdated = false; try { if (hasKey(key)) { byte[] serializedKey = serialize(key); byte[] serializedSequenceId = serialize(sequenceId); if (redis.hexists(serializedKey, serializedSequenceId)) { redis.hset(serializedKey, serializedSequenceId, value); isUpdated = true; } } } catch (IOException e) { e.printStackTrace(); } return isUpdated; } 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 testUpdate() { byte[] serializedValue = "foo".getBytes(); String key = dbHandler.store(serializedValue); boolean b = dbHandler.update(key, 0, "foobar".getBytes()); assertTrue(b); }