@Override
    public void savePublishedItem( PublishedItem item )
    {
        log.debug( "Saving published item for node {}: {}", item.getNode().getUniqueIdentifier(), item.getID() );
        final Lock lock = itemsCache.getLock(item.getNode().getUniqueIdentifier());
        lock.lock();
        try {

            // Find and remove an item with the same ID, if one is present.
            final HashSet<PublishedItem> allNodeItems = itemsCache.get(item.getNode().getUniqueIdentifier());
            if (allNodeItems != null) {
                final Optional<PublishedItem> oldItem = allNodeItems.stream().filter(i -> i.getUniqueIdentifier().equals(item.getUniqueIdentifier())).findAny();
                oldItem.ifPresent(publishedItem -> CacheUtil.removeValueFromMultiValuedCache(itemsCache, item.getNode().getUniqueIdentifier(), publishedItem));
            }

            // Add the new item.
            CacheUtil.addValueToMultiValuedCache( itemsCache, item.getNode().getUniqueIdentifier(), item, HashSet::new );
        } finally {
            lock.unlock();
        }
    }
Cache that holds all published items (mapped by node ID).
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/InMemoryPubSubPersistenceProvider.java