createCommand() 공개 메소드

public createCommand ( $commandID, $arguments = [] )
예제 #1
0
파일: Redis.php 프로젝트: alambike/phpback
 /**
  * * Add a value to the cache under a unique key
  *
  * @param string $key
  * @param mixed  $value
  * @param int    $ttl
  */
 public function set($key, $value, $ttl = null)
 {
     $this->client->set($key, $value);
     if ($ttl) {
         $cmd = $this->client->createCommand('EXPIRE');
         $cmd->setArguments(array($key, $ttl));
         $this->client->executeCommand($cmd);
     }
 }
예제 #2
0
파일: Predis.php 프로젝트: jeffery/Cache
 /**
  * {@inheritdoc}
  */
 public function set($key, $value, $ttl = null)
 {
     $this->predis->set($key, $this->pack($value));
     if (!$ttl) {
         $ttl = $this->ttl;
     }
     $cmd = $this->predis->createCommand('EXPIRE');
     $cmd->setArguments([$key, $ttl]);
     $this->predis->executeCommand($cmd);
 }
예제 #3
0
 /**
  * @param string         $cmd     The command
  * @param Counter|string $counter The counter
  * @param int            $value   The value
  *
  * @return Counter
  */
 protected function doIncrement($cmd, $counter, $value)
 {
     $counter = $this->transformCounter($counter);
     $cmd = $this->client->createCommand($cmd, array($counter->getName(), $value));
     $value = (int) $this->client->executeCommand($cmd);
     return new Counter($counter->getName(), $value);
 }
예제 #4
0
 /**
  * @param string[] $tags
  * @return string[] Ids
  */
 public function getIdsByAnyTags(array $tags)
 {
     $command = $this->redis->createCommand('sunion', $this->getIdsForTagKeys($tags));
     $response = $this->redis->executeCommand($command);
     if ($response instanceof ResponseErrorInterface) {
         return null;
     }
     return $response;
 }
예제 #5
0
 /**
  * Execute commands
  * 
  * @param string $command
  * @param array $parameters
  * 
  * @return mixed
  */
 public function execute($command, $parameters = array())
 {
     try {
         $cmdSet = $this->client->createCommand($command, $parameters);
         return $this->client->executeCommand($cmdSet);
     } catch (\Exception $e) {
         $this->exception = $e;
         return false;
     }
 }
예제 #6
0
 /**
  * @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()));
 }
예제 #7
0
 /**
  * clear all redis cache.
  */
 public function clear()
 {
     $this->redis->executeCommand($this->redis->createCommand('FLUSHALL'));
 }
예제 #8
0
 /**
  * Execute a Predis command
  *
  * @param   string  $name
  * @param   array   $arguments
  * @return  mixed
  */
 protected function executeCommand($name, array $arguments)
 {
     $command = $this->client->createCommand($name, $arguments);
     return $this->client->executeCommand($command);
 }