### Question:
HashHistoryHolder implements MessagesHistoryHolder<T> { @Override public synchronized boolean storeIfUnknownMessageId(T id) { if (!isKnownMessageId(id)) { set.add(id); return false; } else return true; } HashHistoryHolder(final int tailLength); @Override synchronized boolean storeIfUnknownMessageId(T id); @Override synchronized boolean isKnownMessageId(T id);  }### Answer:
@Test public void testBasicStuff_1() { val history = new HashHistoryHolder<String>(1024); val first = java.util.UUID.randomUUID().toString(); assertFalse(history.storeIfUnknownMessageId(first)); assertTrue(history.storeIfUnknownMessageId(first)); for (int e = 0; e < 1000; e++) { assertFalse(history.storeIfUnknownMessageId(String.valueOf(e))); } assertTrue(history.storeIfUnknownMessageId(first)); }
@Test public void testBasicStuff_2() { val history = new HashHistoryHolder<String>(2048); val iterations = 1000000; val timeStart = System.nanoTime(); for (int e = 0; e < iterations; e++) { assertFalse(history.storeIfUnknownMessageId(String.valueOf(e))); } val timeStop= System.nanoTime(); log.info("Average time per iteration: [{} us]", (timeStop - timeStart) / iterations); }