code: public void addMessageToCache(Message message) {
          messages.compute(message.getId(), (key, value) -> {
              if ((value == null) || (value.get() == null)) {
                  WeakReference<Message> result = new WeakReference<>(message, messagesCleanupQueue);
                  messageIdByRef.put(result, key);
                  return result;
              }
              return value;
          });
      }
docs: Adds a message to the cache.
  
  @param message The message to add.