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


PHP ServerProfile::getDefault方法代码示例

本文整理汇总了PHP中Predis\Profile\ServerProfile::getDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerProfile::getDefault方法的具体用法?PHP ServerProfile::getDefault怎么用?PHP ServerProfile::getDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predis\Profile\ServerProfile的用法示例。


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

示例1: getDefault

 /**
  * {@inheritdoc}
  */
 public function getDefault(ClientOptionsInterface $options)
 {
     $profile = ServerProfile::getDefault();
     if (isset($options->prefix)) {
         $profile->setProcessor($options->prefix);
     }
     return $profile;
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:11,代码来源:ClientProfile.php

示例2: testConstructorOpensContext

 /**
  * @group disconnected
  */
 public function testConstructorOpensContext()
 {
     $cmdMonitor = ServerProfile::getDefault()->createCommand('monitor');
     $connection = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $client = $this->getMock('Predis\\Client', array('createCommand', 'executeCommand'), array($connection));
     $client->expects($this->once())->method('createCommand')->with('monitor', array())->will($this->returnValue($cmdMonitor));
     $client->expects($this->once())->method('executeCommand')->with($cmdMonitor);
     $monitor = new MonitorContext($client);
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:12,代码来源:MonitorContextTest.php

示例3: testExecuteCommandDoesNotSendCommandsWithoutExecute

 /**
  * @group disconnected
  */
 public function testExecuteCommandDoesNotSendCommandsWithoutExecute()
 {
     $profile = ServerProfile::getDefault();
     $executor = $this->getMock('Predis\\Pipeline\\PipelineExecutorInterface');
     $executor->expects($this->never())->method('executor');
     $pipeline = new PipelineContext(new Client(), $executor);
     $pipeline->executeCommand($profile->createCommand('echo', array('one')));
     $pipeline->executeCommand($profile->createCommand('echo', array('two')));
     $pipeline->executeCommand($profile->createCommand('echo', array('three')));
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:13,代码来源:PipelineContextTest.php

示例4: testCallingRedisCommandExecutesInstanceOfCommand

 /**
  * @group disconnected
  */
 public function testCallingRedisCommandExecutesInstanceOfCommand()
 {
     $ping = ServerProfile::getDefault()->createCommand('ping', array());
     $connection = $this->getMock('Predis\\Connection\\ConnectionInterface');
     $connection->expects($this->once())->method('executeCommand')->with($this->isInstanceOf('Predis\\Command\\ConnectionPing'))->will($this->returnValue('PONG'));
     $profile = $this->getMock('Predis\\Profile\\ServerProfileInterface');
     $profile->expects($this->once())->method('createCommand')->with('ping', array())->will($this->returnValue($ping));
     $options = array('profile' => $profile);
     $client = $this->getMock('Predis\\Client', null, array($connection, $options));
     $this->assertTrue($client->ping());
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:14,代码来源:ClientTest.php

示例5: testChainOfProcessors

 /**
  * @group disconnected
  */
 public function testChainOfProcessors()
 {
     $processor = $this->getMock('Predis\\Command\\Processor\\CommandProcessorInterface');
     $processor->expects($this->exactly(2))->method('process');
     $chain = new ProcessorChain();
     $chain->add($processor);
     $chain->add($processor);
     $profile = ServerProfile::getDefault();
     $profile->setProcessor($chain);
     $profile->createCommand('info');
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-quick-start-cn,代码行数:14,代码来源:ServerProfileTest.php

示例6: testCreatesNewCommandUsingSpecifiedProfile

 /**
  * @group disconnected
  */
 public function testCreatesNewCommandUsingSpecifiedProfile()
 {
     $ping = ServerProfile::getDefault()->createCommand('ping', array());
     $profile = $this->getMock('Predis\\Profile\\ServerProfileInterface');
     $profile->expects($this->once())->method('createCommand')->with('ping', array())->will($this->returnValue($ping));
     $client = new Client(null, array('profile' => $profile));
     $this->assertSame($ping, $client->createCommand('ping', array()));
 }
开发者ID:tystr,项目名称:predis-async,代码行数:11,代码来源:ClientTest.php

示例7: testThrowsExceptionOnNonSupportedCommand

 /**
  * @group disconnected
  * @expectedException Predis\NotSupportedException
  * @expectedExceptionMessage Cannot use PING with redis-cluster
  */
 public function testThrowsExceptionOnNonSupportedCommand()
 {
     $ping = ServerProfile::getDefault()->createCommand('ping');
     $cluster = new RedisCluster();
     $cluster->add($this->getMockConnection('tcp://127.0.0.1:6379'));
     $cluster->getConnection($ping);
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-quick-start-cn,代码行数:12,代码来源:RedisClusterTest.php

示例8: testValidationDoesNotSetPrefixProcessorWhenValueIsProfileInstance

 /**
  * @group disconnected
  */
 public function testValidationDoesNotSetPrefixProcessorWhenValueIsProfileInstance()
 {
     $options = $this->getMock('Predis\\Option\\ClientOptions', array('__isset', '__get'));
     $options->expects($this->never())->method('__isset');
     $options->expects($this->never())->method('__get');
     $option = new ClientProfile();
     $profile = $option->filter($options, ServerProfile::getDefault());
     $this->assertInstanceOf('Predis\\Profile\\ServerProfileInterface', $profile);
     $this->assertNull($profile->getProcessor());
 }
开发者ID:surjit,项目名称:node-redis-php-chat-app,代码行数:13,代码来源:ClientProfileTest.php

示例9: testIterationRewindable

 /**
  * @group disconnected
  */
 public function testIterationRewindable()
 {
     $client = $this->getMock('Predis\\Client', array('getProfile', 'lrange'));
     $client->expects($this->any())->method('getProfile')->will($this->returnValue(ServerProfile::getDefault()));
     $client->expects($this->exactly(2))->method('lrange')->with('key:list', 0, 9)->will($this->returnValue(array('item:1', 'item:2')));
     $iterator = new ListKey($client, 'key:list');
     $iterator->rewind();
     $this->assertTrue($iterator->valid());
     $this->assertSame('item:1', $iterator->current());
     $this->assertSame(0, $iterator->key());
     $iterator->rewind();
     $this->assertTrue($iterator->valid());
     $this->assertSame('item:1', $iterator->current());
     $this->assertSame(0, $iterator->key());
     $iterator->next();
     $this->assertTrue($iterator->valid());
     $this->assertSame(1, $iterator->key());
     $this->assertSame('item:2', $iterator->current());
     $iterator->next();
     $this->assertFalse($iterator->valid());
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:24,代码来源:ListKeyTest.php

示例10: testExecuteCommandOnEachNode

 /**
  * @group disconnected
  */
 public function testExecuteCommandOnEachNode()
 {
     $ping = ServerProfile::getDefault()->createCommand('ping', array());
     $connection1 = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $connection1->expects($this->once())->method('executeCommand')->with($ping)->will($this->returnValue(true));
     $connection2 = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $connection2->expects($this->once())->method('executeCommand')->with($ping)->will($this->returnValue(false));
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     $this->assertSame(array(true, false), $cluster->executeCommandOnNodes($ping));
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:15,代码来源:PredisClusterTest.php

示例11: testAcceptsCallableToOverrideReadOnlyFlagForCommands

 /**
  * @group disconnected
  */
 public function testAcceptsCallableToOverrideReadOnlyFlagForCommands()
 {
     $profile = ServerProfile::getDefault();
     $cmdExistsFoo = $profile->createCommand('exists', array('foo'));
     $cmdExistsBar = $profile->createCommand('exists', array('bar'));
     $master = $this->getMockConnection('tcp://host1?alias=master');
     $master->expects($this->once())->method('executeCommand')->with($cmdExistsBar);
     $slave1 = $this->getMockConnection('tcp://host2?alias=slave1');
     $slave1->expects($this->once())->method('executeCommand')->with($cmdExistsFoo);
     $replication = new MasterSlaveReplication();
     $replication->add($master);
     $replication->add($slave1);
     $replication->setCommandReadOnly('exists', function ($cmd) {
         list($arg1) = $cmd->getArguments();
         return $arg1 === 'foo';
     });
     $replication->executeCommand($cmdExistsFoo);
     $replication->executeCommand($cmdExistsBar);
 }
开发者ID:rubensayshi,项目名称:predis,代码行数:22,代码来源:MasterSlaveReplicationTest.php

示例12: create

 /**
  * {@inheritdoc}
  */
 public function create($parameters, ServerProfileInterface $profile = null)
 {
     if (!$parameters instanceof ConnectionParametersInterface) {
         $parameters = new ConnectionParameters($parameters ?: array());
     }
     $scheme = $parameters->scheme;
     if (!isset($this->schemes[$scheme])) {
         throw new \InvalidArgumentException("Unknown connection scheme: {$scheme}");
     }
     $initializer = $this->schemes[$scheme];
     if (!is_callable($initializer)) {
         $connection = new $initializer($parameters);
         $this->prepareConnection($connection, $profile ?: ServerProfile::getDefault());
         return $connection;
     }
     $connection = call_user_func($initializer, $parameters, $profile);
     if (!$connection instanceof SingleConnectionInterface) {
         throw new \InvalidArgumentException('Objects returned by connection initializers must implement ' . 'Predis\\Connection\\SingleConnectionInterface');
     }
     return $connection;
 }
开发者ID:rubensayshi,项目名称:predis,代码行数:24,代码来源:ConnectionFactory.php

示例13: __construct

 /**
  *
  */
 public function __construct(ServerProfileInterface $profile = null)
 {
     $this->setProfile($profile ?: ServerProfile::getDefault());
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:7,代码来源:MultiExecExecutor.php

示例14: __construct

 /**
  *
  */
 public function __construct()
 {
     $this->setProfile(ServerProfile::getDefault());
 }
开发者ID:rubensayshi,项目名称:predis,代码行数:7,代码来源:MultiExecExecutor.php


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