/** * Create command * * @param string $key Key name * @param boolean $responseIterator[optional] If true - command return iterator which read from socket buffer. * Important: new connection will be created * @return Rediska_Connection_Exec */ public function create($key, $responseIterator = false) { $connection = $this->_rediska->getConnectionByKeyName($key); $command = array('SMEMBERS', $this->_rediska->getOption('namespace') . $key); $exec = new Rediska_Connection_Exec($connection, $command); if ($responseIterator) { $exec->setResponseIterator(true); $exec->setResponseCallback(array($this->getRediska()->getSerializer(), 'unserialize')); } return $exec; }
/** * Create command * * @param string $key Key name * @param integer $withScores[optional] Return values with scores. For default is false. * @param integer $start[optional] Start index. For default is begin of set. * @param integer $end[optional] End index. For default is end of set. * @param boolean $revert[optional] Revert elements (not used in sorting). For default is false * @param boolean $responseIterator[optional] If true - command return iterator which read from socket buffer. * Important: new connection will be created * @return Rediska_Connection_Exec */ public function create($key, $withScores = false, $start = 0, $end = -1, $revert = false, $responseIterator = false) { $connection = $this->_rediska->getConnectionByKeyName($key); $command = array($revert ? 'ZREVRANGE' : 'ZRANGE', $this->_rediska->getOption('namespace') . $key, $start, $end); if ($withScores) { $command[] = 'WITHSCORES'; } $exec = new Rediska_Connection_Exec($connection, $command); if ($responseIterator) { if ($withScores) { $responseIterator = 'Rediska_Command_GetSortedSet_WithScoresIterator'; } $exec->setResponseIterator($responseIterator); $exec->setResponseCallback(array($this, 'parseIteratorResponse')); } return $exec; }