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;
        });
    }
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 ; } ) ; }
Adds a message to the cache.

@param message The message to add.