RedisDBHandler implements IDBHandler { @Override public boolean hasKey(String key) { boolean returnVal = false; try { if (redis.exists(serialize(key))) { returnVal = true; } } catch (IOException e) { e.printStackTrace(); } return returnVal; } 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 testHasKey() { String key; try { key = dbHandler.store(serialize("foo")); assertTrue(dbHandler.hasKey(key)); assertFalse(dbHandler.hasKey("foobar")); } catch (IOException e) { e.printStackTrace(); } }