public function cleanBySurrogateKey($keys)
    {
        $type = 'clean by key on ';
        $uri = $this->_getApiServiceUri() . 'purge';
        $num = count($keys);
        $result = false;
        if ($num >= self::FASTLY_MAX_HEADER_KEY_SIZE) {
            $parts = $num / self::FASTLY_MAX_HEADER_KEY_SIZE;
            $additional = ($parts > (int)$parts) ? 1 : 0;
            $parts = (int)$parts + (int)$additional;
            $chunks = ceil($num/$parts);
            $collection = array_chunk($keys, $chunks);
        } else {
            $collection = [$keys];
        }

        foreach ($collection as $keys) {
            $payload = json_encode(['surrogate_keys' => $keys]);
            $result = $this->_purge($uri, null, \Zend_Http_Client::POST, $payload);
            if ($result['status']) {
                foreach ($keys as $key) {
                    $this->logger->execute('surrogate key: ' . $key);
                }
            }

            $canPublishKeyUrlChanges = $this->config->canPublishKeyUrlChanges();
            $canPublishPurgeChanges = $this->config->canPublishPurgeChanges();

            if ($this->config->areWebHooksEnabled() && ($canPublishKeyUrlChanges || $canPublishPurgeChanges)) {
                $status = $result['status'] ? '' : 'FAILED ';
                $this->sendWebHook($status . '*clean by key on ' . join(" ", $keys) . '*');

                $canPublishPurgeByKeyDebugBacktrace = $this->config->canPublishPurgeByKeyDebugBacktrace();
                $canPublishPurgeDebugBacktrace = $this->config->canPublishPurgeDebugBacktrace();

                if ($canPublishPurgeByKeyDebugBacktrace == false && $canPublishPurgeDebugBacktrace == false) {
                    return $result['status'];
                }

                $this->stackTrace($type . join(" ", $keys));
            }
        }

        return $result['status'];
    }
public function cleanBySurrogateKey($keys)
    {
        $type = 'clean by key on ';
        $uri = $this->_getApiServiceUri() . 'purge';
        $num = count($keys);
        $result = false;
        if ($num >= self::FASTLY_MAX_HEADER_KEY_SIZE) {
            $parts = $num / self::FASTLY_MAX_HEADER_KEY_SIZE;
            $additional = ($parts > (int)$parts) ? 1 : 0;
            $parts = (int)$parts + (int)$additional;
            $chunks = ceil($num/$parts);
            $collection = array_chunk($keys, $chunks);
        } else {
            $collection = [$keys];
        }

        foreach ($collection as $keys) {
            $payload = json_encode(['surrogate_keys' => $keys]);
            $result = $this->_purge($uri, null, \Zend_Http_Client::POST, $payload);
            if ($result['status']) {
                foreach ($keys as $key) {
                    $this->logger->execute('surrogate key: ' . $key);
                }
            }

            $canPublishKeyUrlChanges = $this->config->canPublishKeyUrlChanges();
            $canPublishPurgeChanges = $this->config->canPublishPurgeChanges();

            if ($this->config->areWebHooksEnabled() && ($canPublishKeyUrlChanges || $canPublishPurgeChanges)) {
                $status = $result['status'] ? '' : 'FAILED ';
                $this->sendWebHook($status . '*clean by key on ' . join(" ", $keys) . '*');

                $canPublishPurgeByKeyDebugBacktrace = $this->config->canPublishPurgeByKeyDebugBacktrace();
                $canPublishPurgeDebugBacktrace = $this->config->canPublishPurgeDebugBacktrace();

                if ($canPublishPurgeByKeyDebugBacktrace == false && $canPublishPurgeDebugBacktrace == false) {
                    return $result['status'];
                }

                $this->stackTrace($type . join(" ", $keys));
            }
        }

        return $result['status'];
    }
public function cleanBySurrogateKey ( $ keys ) { $ type = 'clean by key on ' ; $ uri = $ this -> _getApiServiceUri ( ) . 'purge' ; $ num = count ( $ keys ) ; $ result = false ; if ( $ num >= self :: FASTLY_MAX_HEADER_KEY_SIZE ) { $ parts = $ num / self :: FASTLY_MAX_HEADER_KEY_SIZE ; $ additional = ( $ parts > ( int ) $ parts ) ? 1 : 0 ; $ parts = ( int ) $ parts + ( int ) $ additional ; $ chunks = ceil ( $ num / $ parts ) ; $ collection = array_chunk ( $ keys , $ chunks ) ; } else { $ collection = [ $ keys ] ; } foreach ( $ collection as $ keys ) { $ payload = json_encode ( [ 'surrogate_keys' => $ keys ] ) ; $ result = $ this -> _purge ( $ uri , null , \ Zend_Http_Client :: POST , $ payload ) ; if ( $ result [ 'status' ] ) { foreach ( $ keys as $ key ) { $ this -> logger -> execute ( 'surrogate key: ' . $ key ) ; } } $ canPublishKeyUrlChanges = $ this -> config -> canPublishKeyUrlChanges ( ) ; $ canPublishPurgeChanges = $ this -> config -> canPublishPurgeChanges ( ) ; if ( $ this -> config -> areWebHooksEnabled ( ) && ( $ canPublishKeyUrlChanges || $ canPublishPurgeChanges ) ) { $ status = $ result [ 'status' ] ? '' : 'FAILED ' ; $ this -> sendWebHook ( $ status . '*clean by key on ' . join ( " " , $ keys ) . '*' ) ; $ canPublishPurgeByKeyDebugBacktrace = $ this -> config -> canPublishPurgeByKeyDebugBacktrace ( ) ; $ canPublishPurgeDebugBacktrace = $ this -> config -> canPublishPurgeDebugBacktrace ( ) ; if ( $ canPublishPurgeByKeyDebugBacktrace == false && $ canPublishPurgeDebugBacktrace == false ) { return $ result [ 'status' ] ; } $ this -> stackTrace ( $ type . join ( " " , $ keys ) ) ; } } return $ result [ 'status' ] ; }
Purge Fastly by a given surrogate key

@param $keys
@return bool|\Magento\Framework\Controller\Result\Json
@throws \Zend_Uri_Exception
Purge Fastly by a given surrogate key