public function BloomFilter_check($namespace, $str) { $data = [['SELECT', '8']]; foreach ($this->seeds as $value) { $hash = phpiredis_murmur3($str, $value); $data[] = ["getBit", $namespace, (string) $hash]; } $res = phpiredis_multi_command_bs($this->conn, $data); if ($res[0] != "OK") { return false; } array_shift($res); foreach ($res as $value) { if ($value === 0) { return false; } } return true; }
/** * @return array */ public function pipelineExecute() { // no connection? if ($this->_getRedisInstance() === FALSE) { return FALSE; } $_pipeline = $this->_pipelineGetQueue(); $requestResponsesMulti = ['errors' => [], 'responses' => []]; // run through all commands $responsesMulti = phpiredis_multi_command_bs($this->_getRedisInstance(), $_pipeline); // build request/response array foreach ($responsesMulti as $index => $response) { $_requestKey = json_encode($_pipeline[$index]); if (is_array($response) || substr($response, 0, 3) !== 'ERR') { $requestResponsesMulti['responses'][$_requestKey] = $response; continue; } $requestResponsesMulti['error'][$_requestKey] = $response; } // reset request/response queues $this->_pipelineResetQueue(); // disable pipeline $this->pipelineEnable(FALSE); return $requestResponsesMulti; }
/** * @see multi() * @link http://redis.io/commands/exec */ public function exec() { $results = []; if ($this->isInStreamMode()) { // In pipeline mode we have to send all buffered commands phpiredis_multi_command_bs($this->connection, $this->pipeCommands); } else { if ($this->isInPipelineMode()) { // extract just the commands $commands = array_map(function ($pipeCmd) { return $pipeCmd[0]; }, $this->pipeCommands); $results = phpiredis_multi_command_bs($this->connection, $commands); } else { // In any other mode we just send 'EXEC' $results = phpiredis_command_bs($this->connection, array('EXEC')); } } // If we have been in any batch mode, reset mode and post process all results if ($this->isInBatchMode()) { $this->multiState = 0; // phpiredis returns false when something went wrong, so we have to check here if (is_array($results) && !empty($results)) { // do post processing on the results by calling the appropriate post processing function for each command $this->walkPostProcessingCallbacks($results); } } // done $this->pipeCommands = array(); return $results; }