src/Validator/NodeIdempotencyValidator.php
public function onCreateNodeAfterHandle(PbjxEvent $pbjxEvent): void
    {
        $command = $pbjxEvent->getMessage();
        if (!$command->has('node')) {
            return;
        }

        /** @var Node $node */
        $node = $command->get('node');
        if ($this->shouldIgnoreNode($node)) {
            return;
        }

        /** @var CacheItemInterface[] $cacheItems */
        $cacheItems = $this->cache->getItems($this->getIdempotencyKeys($node));

        foreach ($cacheItems as $cacheItem) {
            $cacheItem->set(true)->expiresAfter($this->getCacheTtl($node));
            $this->cache->saveDeferred($cacheItem);
        }
    }
public function onCreateNodeAfterHandle(PbjxEvent $pbjxEvent): void
    {
        $command = $pbjxEvent->getMessage();
        if (!$command->has('node')) {
            return;
        }

        /** @var Node $node */
        $node = $command->get('node');
        if ($this->shouldIgnoreNode($node)) {
            return;
        }

        /** @var CacheItemInterface[] $cacheItems */
        $cacheItems = $this->cache->getItems($this->getIdempotencyKeys($node));

        foreach ($cacheItems as $cacheItem) {
            $cacheItem->set(true)->expiresAfter($this->getCacheTtl($node));
            $this->cache->saveDeferred($cacheItem);
        }
    }
public function onCreateNodeAfterHandle ( PbjxEvent $ pbjxEvent ) : void { $ command = $ pbjxEvent -> getMessage ( ) ; if ( ! $ command -> has ( 'node' ) ) { return ; } /** @var Node $node */ $ node = $ command -> get ( 'node' ) ; if ( $ this -> shouldIgnoreNode ( $ node ) ) { return ; } /** @var CacheItemInterface[] $cacheItems */ $ cacheItems = $ this -> cache -> getItems ( $ this -> getIdempotencyKeys ( $ node ) ) ; foreach ( $ cacheItems as $ cacheItem ) { $ cacheItem -> set ( true ) -> expiresAfter ( $ this -> getCacheTtl ( $ node ) ) ; $ this -> cache -> saveDeferred ( $ cacheItem ) ; } }
Populates cache keys so idempotency check can reject duplicates
after nodes are successfully created.

@param PbjxEvent $pbjxEvent
Populates cache keys so idempotency check can reject duplicates after nodes are successfully created .