docs: @SuppressWarnings("unchecked")
      public void set(long sequenceId, T item) {
          final E rbItem = convertToRingbufferFormat(item);
  
          // first we write the dataItem in the ring.
          ringbuffer.set(sequenceId, rbItem);
  
          if (sequenceId > tailSequence()) {
              ringbuffer.setTailSequence(sequenceId);
  
              if (ringbuffer.size() > ringbuffer.getCapacity()) {
                  ringbuffer.setHeadSequence(ringbuffer.tailSequence() - ringbuffer.getCapacity() + 1);
              }
          }
          if (sequenceId < headSequence()) {
              ringbuffer.setHeadSequence(sequenceId);
          }
  
          // and then we optionally write the expiration.
          if (expirationPolicy != null) {
              expirationPolicy.setExpirationAt(sequenceId);
          }
      }