public void put(T element) {
    if (cache.size() > cacheSize) {
      Iterator iterator = cache.iterator();
      if (iterator.hasNext()) {
        iterator.remove();
      }
    }
    cache.add(element);
  }
LinkedinHashSet of bounded size {@code size} with a FIFO eviction policy

This class is not thread-safe
samza-core/src/main/java/org/apache/samza/util/BoundedLinkedHashSet.java