code: public void removeMessage(Message message) {
          synchronized (messages) {
              messages.removeIf(messageRef -> Objects.equals(messageRef.get(), message));
          }
      }
docs: Removes a message from the cache.
  
  @param message The message to remove.