@Override
    public void removeSubscription(NodeSubscription subscription) {
        log.debug( "Removing node subscription for owner {} to node {} (subscription ID: {})", subscription.getOwner(), subscription.getNode().getUniqueIdentifier(), subscription.getID() );

        final List<NodeOperation> operations = nodesToProcess.computeIfAbsent( subscription.getNode().getUniqueIdentifier(), id -> new ArrayList<>() );

        // This subscription removal can replace any pending creation or update of the same subscription (since the last create/delete of the node or subscription change of this subscription to the node).
        boolean hadCreate = false;
        final ListIterator<NodeOperation> iter = operations.listIterator( operations.size() );
        while ( iter.hasPrevious() ) {
            final NodeOperation operation = iter.previous();
            if ( Arrays.asList( NodeOperation.Action.CREATE_SUBSCRIPTION, NodeOperation.Action.UPDATE_SUBSCRIPTION ).contains( operation.action ) ) {
                if ( subscription.getID().equals( operation.subscription.getID() ) ) {
                    if (operation.action == NodeOperation.Action.CREATE_SUBSCRIPTION) {
                        hadCreate = true;
                    }
                    iter.remove(); // This is replaced by the update that's being added.
                }
            } else {
                break; // Operations that precede anything other than the last operations that are subscription changes shouldn't be replaced.
            }
        }

        if (!hadCreate) { // If one of the operations that have not been executed was a subscription create, we need not delete the subscription either.
            operations.add(NodeOperation.removeSubscription(subscription.getNode(), subscription));
        }
    }
Cache for recently accessed published items.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/CachingPubsubPersistenceProvider.java