Exemple #1
0
 /**
  * Send curl purge request
  * to invalidate cache by tags pattern
  *
  * @param string $tagsPattern
  * @return void
  */
 protected function sendPurgeRequest($tagsPattern)
 {
     $headers = ["X-Magento-Tags-Pattern: {$tagsPattern}"];
     $this->_curlAdapter->setOptions([CURLOPT_CUSTOMREQUEST => 'PURGE']);
     $this->_curlAdapter->write('', $this->_helper->getUrl('*'), '1.1', $headers);
     $this->_curlAdapter->read();
     $this->_curlAdapter->close();
     $this->logger->execute(compact('tagsPattern'));
 }
 /**
  * Send curl purge request
  * to invalidate cache by tags pattern
  *
  * @param string $tagsPattern
  * @return bool Return true if successful; otherwise return false
  */
 public function sendPurgeRequest($tagsPattern)
 {
     $socketAdapter = $this->socketAdapterFactory->create();
     $servers = $this->cacheServer->getUris();
     $headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $tagsPattern];
     $socketAdapter->setOptions(['timeout' => 10]);
     foreach ($servers as $server) {
         try {
             $socketAdapter->connect($server->getHost(), $server->getPort());
             $socketAdapter->write('PURGE', $server, '1.1', $headers);
             $socketAdapter->close();
         } catch (\Exception $e) {
             $this->logger->critical($e->getMessage(), compact('server', 'tagsPattern'));
             return false;
         }
     }
     $this->logger->execute(compact('servers', 'tagsPattern'));
     return true;
 }
Exemple #3
0
 /**
  * @param mixed $args
  * @return void
  */
 public function log($args)
 {
     $this->logger->execute($args);
 }