當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Profile\ServerProfile類代碼示例

本文整理匯總了PHP中Predis\Profile\ServerProfile的典型用法代碼示例。如果您正苦於以下問題:PHP ServerProfile類的具體用法?PHP ServerProfile怎麽用?PHP ServerProfile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ServerProfile類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getCommandsQueue

 /**
  * Returns a list of queued command instances.
  *
  * @return SplQueue
  */
 protected function getCommandsQueue()
 {
     $profile = ServerProfile::getDevelopment();
     $pipeline = new SplQueue();
     $pipeline->enqueue($profile->createCommand('ping'));
     $pipeline->enqueue($profile->createCommand('ping'));
     $pipeline->enqueue($profile->createCommand('ping'));
     return $pipeline;
 }
開發者ID:GeorgeBroadley,項目名稱:caffeine-vendor,代碼行數:14,代碼來源:FireAndForgetExecutorTest.php

示例3: 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

示例4: 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

示例5: testClosingContextWithFalseSendsUnsubscriptions

 /**
  * @group disconnected
  */
 public function testClosingContextWithFalseSendsUnsubscriptions()
 {
     $profile = ServerProfile::get(REDIS_SERVER_VERSION);
     $classUnsubscribe = $profile->getCommandClass('unsubscribe');
     $classPunsubscribe = $profile->getCommandClass('punsubscribe');
     $connection = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $client = $this->getMock('Predis\\Client', array('disconnect'), array($connection));
     $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*');
     $pubsub = new PubSubContext($client, $options);
     $connection->expects($this->exactly(2))->method('writeCommand')->with($this->logicalOr($this->isInstanceOf($classUnsubscribe), $this->isInstanceOf($classPunsubscribe)));
     $pubsub->closeContext(false);
 }
開發者ID:shinichi81,項目名稱:laravel4demo,代碼行數:15,代碼來源:PubSubContextTest.php

示例6: testSettingCustomCommandHandler

 /**
  * @group disconnected
  */
 public function testSettingCustomCommandHandler()
 {
     $strategy = $this->getHashStrategy();
     $profile = ServerProfile::getDevelopment();
     $callable = $this->getMock('stdClass', array('__invoke'));
     $callable->expects($this->once())->method('__invoke')->with($this->isInstanceOf('Predis\\Command\\CommandInterface'))->will($this->returnValue('key'));
     $strategy->setCommandHandler('get', $callable);
     $command = $profile->createCommand('get', array('key'));
     $this->assertNotNull($strategy->getHash($command));
 }
開發者ID:ningcaichen,項目名稱:laravel-4.1-quick-start-cn,代碼行數:13,代碼來源:PredisClusterHashStrategyTest.php

示例7: getScript

local hashes = {}
for _, key in pairs(KEYS) do
    table.insert(hashes, key)
    table.insert(hashes, redis.call('hgetall', key))
end
return hashes
EOS;
    public function getScript()
    {
        return self::BODY;
    }
}
// ------------------------------------------------------------------------- //
$parameters = array('tcp://127.0.0.1:6379/?alias=master', 'tcp://127.0.0.1:6380/?alias=slave');
$options = array('profile' => function ($options) {
    $profile = ServerProfile::get('2.6');
    $profile->defineCommand('hmgetall', 'HashMultipleGetAll');
    return $profile;
}, 'replication' => function ($options) {
    $replication = new MasterSlaveReplication();
    $replication->setScriptReadOnly(HashMultipleGetAll::BODY);
    return $replication;
});
// ------------------------------------------------------------------------- //
$client = new Predis\Client($parameters, $options);
// Execute the following commands on the master server using redis-cli:
// $ ./redis-cli HMSET metavars foo bar hoge piyo
// $ ./redis-cli HMSET servers master host1 slave host2
$hashes = $client->hmgetall('metavars', 'servers');
$replication = $client->getConnection();
$stillOnSlave = $replication->getCurrent() === $replication->getConnectionById('slave');
開發者ID:rubensayshi,項目名稱:predis,代碼行數:31,代碼來源:MasterSlaveReplicationComplex.php

示例8: 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

示例9: 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

示例10: getProfile

 /**
  * Returns a new instance of server profile.
  *
  * @param  string                 $version Redis profile.
  * @return ServerProfileInterface
  */
 protected function getProfile($version = null)
 {
     return ServerProfile::get($version ?: REDIS_SERVER_VERSION);
 }
開發者ID:ningcaichen,項目名稱:laravel-4.1-quick-start-cn,代碼行數:10,代碼來源:PredisTestCase.php

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: testCanSetReadOnlyFlagForEvalScripts

 /**
  * @group disconnected
  */
 public function testCanSetReadOnlyFlagForEvalScripts()
 {
     $profile = ServerProfile::get('dev');
     $cmdEval = $profile->createCommand('eval', array($script = "return redis.call('info');"));
     $cmdEvalSha = $profile->createCommand('evalsha', array($scriptSHA1 = sha1($script)));
     $master = $this->getMockConnection('tcp://host1?alias=master');
     $master->expects($this->never())->method('executeCommand');
     $slave1 = $this->getMockConnection('tcp://host2?alias=slave1');
     $slave1->expects($this->exactly(2))->method('executeCommand')->with($this->logicalOr($cmdEval, $cmdEvalSha));
     $replication = new MasterSlaveReplication();
     $replication->add($master);
     $replication->add($slave1);
     $replication->setScriptReadOnly($script);
     $replication->executeCommand($cmdEval);
     $replication->executeCommand($cmdEvalSha);
 }
開發者ID:rubensayshi,項目名稱:predis,代碼行數:19,代碼來源:MasterSlaveReplicationTest.php


注:本文中的Predis\Profile\ServerProfile類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。