当前位置: 首页>>代码示例>>PHP>>正文


PHP Predis\ClientInterface类代码示例

本文整理汇总了PHP中Predis\ClientInterface的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface类的具体用法?PHP ClientInterface怎么用?PHP ClientInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ClientInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(ClientInterface $client)
 {
     if (!$client->getCommandFactory()->supportsCommands(array('multi', 'exec', 'discard'))) {
         throw new ClientException("'MULTI', 'EXEC' and 'DISCARD' are not supported by the current command factory.");
     }
     parent::__construct($client);
 }
开发者ID:nrk,项目名称:predis,代码行数:10,代码来源:Atomic.php

示例2: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(ClientInterface $client)
 {
     if (!$client->getProfile()->supportsCommands(array('multi', 'exec', 'discard'))) {
         throw new ClientException("The current profile does not support 'MULTI', 'EXEC' and 'DISCARD'.");
     }
     parent::__construct($client);
 }
开发者ID:flachesis,项目名称:predis,代码行数:10,代码来源:Atomic.php

示例3: createExecutor

 /**
  * Returns a pipeline executor depending on the kind of the underlying
  * connection and the passed options.
  *
  * @param  ClientInterface           $client Client instance used by the context.
  * @return PipelineExecutorInterface
  */
 protected function createExecutor(ClientInterface $client)
 {
     $options = $client->getOptions();
     if (isset($options->exceptions)) {
         return new StandardExecutor($options->exceptions);
     }
     return new StandardExecutor();
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:15,代码来源:PipelineContext.php

示例4: assertClient

 /**
  * Checks if the passed client instance satisfies the required conditions
  * needed to initialize a monitor consumer.
  *
  * @param ClientInterface $client Client instance used by the consumer.
  *
  * @throws NotSupportedException
  */
 private function assertClient(ClientInterface $client)
 {
     if ($client->getConnection() instanceof AggregateConnectionInterface) {
         throw new NotSupportedException('Cannot initialize a monitor consumer over aggregate connections.');
     }
     if ($client->getProfile()->supportsCommand('MONITOR') === false) {
         throw new NotSupportedException("The current profile does not support 'MONITOR'.");
     }
 }
开发者ID:huycao,项目名称:yodelivery,代码行数:17,代码来源:Consumer.php

示例5: checkCapabilities

 /**
  * Checks if the passed client instance satisfies the required conditions
  * needed to initialize a monitor context.
  *
  * @param ClientInterface $client Client instance used by the context.
  */
 private function checkCapabilities(ClientInterface $client)
 {
     if ($client->getConnection() instanceof AggregatedConnectionInterface) {
         throw new NotSupportedException('Cannot initialize a monitor context when using aggregated connections');
     }
     if ($client->getProfile()->supportsCommand('monitor') === false) {
         throw new NotSupportedException('The current profile does not support the MONITOR command');
     }
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:15,代码来源:MonitorContext.php

示例6: checkCapabilities

 /**
  * Checks if the passed client instance satisfies the required conditions
  * needed to initialize a Publish / Subscribe context.
  *
  * @param ClientInterface $client Client instance used by the context.
  */
 private function checkCapabilities(ClientInterface $client)
 {
     if ($client->getConnection() instanceof AggregatedConnectionInterface) {
         throw new NotSupportedException('Cannot initialize a PUB/SUB context when using aggregated connections');
     }
     $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe');
     if ($client->getProfile()->supportsCommands($commands) === false) {
         throw new NotSupportedException('The current profile does not support PUB/SUB related commands');
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:16,代码来源:PubSubContext.php

示例7: checkCapabilities

 /**
  * Checks if the client instance satisfies the required conditions needed to
  * initialize a PUB/SUB consumer.
  *
  * @param ClientInterface $client Client instance used by the consumer.
  *
  * @throws NotSupportedException
  */
 private function checkCapabilities(ClientInterface $client)
 {
     if ($client->getConnection() instanceof AggregateConnectionInterface) {
         throw new NotSupportedException('Cannot initialize a PUB/SUB consumer over aggregate connections.');
     }
     $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe');
     if ($client->getCommandFactory()->supportsCommands($commands) === false) {
         throw new NotSupportedException('PUB/SUB commands are not supported by the current command factory.');
     }
 }
开发者ID:nrk,项目名称:predis,代码行数:18,代码来源:Consumer.php

示例8: configure

 /**
  * Configures the transaction using the provided options.
  *
  * @param ClientInterface $client  Underlying client instance.
  * @param array           $options Array of options for the transaction.
  * */
 protected function configure(ClientInterface $client, array $options)
 {
     if (isset($options['exceptions'])) {
         $this->exceptions = (bool) $options['exceptions'];
     } else {
         $this->exceptions = $client->getOptions()->exceptions;
     }
     if (isset($options['cas'])) {
         $this->modeCAS = (bool) $options['cas'];
     }
     if (isset($options['watch']) && ($keys = $options['watch'])) {
         $this->watchKeys = $keys;
     }
     if (isset($options['retry'])) {
         $this->attempts = (int) $options['retry'];
     }
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:23,代码来源:MultiExec.php

示例9: broadcast

 /**
  * Broadcast the given event.
  *
  * @param  array $channels
  * @param  string $event
  * @param  array $payload
  * @return void
  */
 public function broadcast(array $channels, $event, array $payload = [])
 {
     $socket = isset($payload['socket']) ? $payload['socket'] : null;
     $payload = json_encode(['event' => $event, 'data' => $payload, 'socket' => $socket]);
     foreach ($this->formatChannels($channels) as $channel) {
         $this->redis->publish($channel, $payload);
     }
 }
开发者ID:edwin-luijten,项目名称:ekko,代码行数:16,代码来源:RedisBroadcaster.php

示例10: has

 /**
  * @inheritdoc
  */
 public function has(AggregateIdInterface $id, $version)
 {
     if (!$this->redis->hexists(static::KEY_NAMESPACE, (string) $id)) {
         return false;
     }
     $snapshot = $this->serializer->deserialize($this->redis->hget(static::KEY_NAMESPACE, (string) $id), 'array', 'json');
     return $snapshot['version'] === $version;
 }
开发者ID:hellofresh,项目名称:engine,代码行数:11,代码来源:RedisSnapshotAdapter.php

示例11: cacheSet

 /**
  * Set the cache for a token.
  *
  * @param $key
  * @param string $value
  * @param null $expiration
  */
 protected function cacheSet($key, $value, $expiration = null)
 {
     $this->client->set($key, $value);
     if (!empty($expiration)) {
         $this->ttl = $expiration;
     }
     $this->client->expire($key, $this->ttl);
 }
开发者ID:cultuurnet,项目名称:symfony-security-oauth-redis,代码行数:15,代码来源:TokenProviderCache.php

示例12: doEnqueue

 /**
  *
  * @throws QueueIsDraining If the Queue is Drainable
  *
  * @param string $message
  * @param array $options Message options (override Queue options):
  *
  * @return string Unique ID along the queue
  */
 protected function doEnqueue($message, $options = [])
 {
     // Score has form <priority>.<timestamp>
     $score = isset($options['score']) ? $options['score'] : 0;
     if ($priority = $this->getOption('priority', false, $options)) {
         $score += $priority;
     }
     $this->redis->zAdd($this->queueKey, $score, $message);
 }
开发者ID:aerogram,项目名称:redis,代码行数:18,代码来源:Queue.php

示例13: release

 /**
  * Releases the lock, if it has not been released already
  */
 public function release()
 {
     if ($this->released) {
         return;
     }
     // Only release the lock if it hasn't expired
     if ($this->expire >= time()) {
         $this->redis->del($this->key);
     }
     $this->released = true;
 }
开发者ID:splitice,项目名称:php-redis-locking,代码行数:14,代码来源:Lock.php

示例14: deleteGlob

 private function deleteGlob($pattern)
 {
     $keys = $this->client->keys($pattern);
     $options = $this->client->getOptions();
     if (isset($options->prefix)) {
         $length = strlen($options->prefix->getPrefix());
         $keys = array_map(function ($key) use($length) {
             return substr($key, $length);
         }, $keys);
     }
     if (count($keys) === 0) {
         return;
     }
     $this->client->del($keys);
 }
开发者ID:genkgo,项目名称:cache,代码行数:15,代码来源:PredisAdapter.php

示例15: removeIndexId

 /**
  * Remove an ID from an index
  * @param  string $id
  * @param  string $index
  * @return void
  */
 protected function removeIndexId(string $id, string $index)
 {
     if ($this->redis->scard($index) == 1) {
         return $this->redis->del($index);
     }
     return $this->redis->srem($index, $id);
 }
开发者ID:phparmory,项目名称:autocomplete,代码行数:13,代码来源:RedisRepository.php


注:本文中的Predis\ClientInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。