Esempio n. 1
0
 /**
  * Create Kafka producer.
  *
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct($params);
     $this->config = new HashConfig($params);
     if (!$this->config->has('KafkaEventHost')) {
         throw new InvalidArgumentException("KafkaEventHost must be configured");
     }
 }
 /**
  * Do the actual async bus purge of a key
  *
  * This must set the key to "PURGED:<UNIX timestamp>"
  *
  * @param string $key Cache key
  * @param integer $ttl How long to keep the tombstone [seconds]
  * @return bool Success
  */
 protected function relayPurge($key, $ttl)
 {
     $event = $this->cache->modifySimpleRelayEvent(array('cmd' => 'set', 'key' => $key, 'val' => 'PURGED:$UNIXTIME$', 'ttl' => max($ttl, 1), 'sbt' => true));
     $ok = $this->relayer->notify("{$this->pool}:purge", $event);
     if (!$ok) {
         $this->lastRelayError = self::ERR_RELAY;
     }
     return $ok;
 }
Esempio n. 3
0
 /**
  * Do the actual async bus delete of a key
  *
  * @param string $key Cache key
  * @return bool Success
  */
 protected function relayDelete($key)
 {
     $event = $this->cache->modifySimpleRelayEvent(array('cmd' => 'delete', 'key' => $key));
     $ok = $this->relayer->notify("{$this->pool}:purge", $event);
     if (!$ok) {
         $this->lastRelayError = self::ERR_RELAY;
     }
     return $ok;
 }
 /**
  * Additional params include 'mcrdConfig', which is a map of:
  *   - url : The base URL of the service (without paths)
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct($params);
     $this->baseUrl = $params['mcrdConfig']['url'];
     $httpConfig = isset($params['httpConfig']) ? $params['httpConfig'] : array();
     if (!isset($httpConfig['connTimeout'])) {
         $httpConfig['connTimeout'] = 1;
     }
     if (!isset($httpConfig['reqTimeout'])) {
         $httpConfig['reqTimeout'] = 0.25;
     }
     $this->http = new MultiHttpClient($httpConfig);
 }