_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q13900 | ReplicationStrategy.isGeoradiusReadOnly | train | protected function isGeoradiusReadOnly(CommandInterface $command)
{
$arguments = $command->getArguments();
$argc = count($arguments);
$startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;
if ($argc > $startIndex) {
for ($i = $startIndex; $i < $argc; ++$i) {
... | php | {
"resource": ""
} |
q13901 | ReplicationStrategy.setCommandReadOnly | train | public function setCommandReadOnly($commandID, $readonly = true)
{
$commandID = strtoupper($commandID);
if ($readonly) {
$this->readonly[$commandID] = $readonly;
} else {
unset($this->readonly[$commandID]);
}
} | php | {
"resource": ""
} |
q13902 | ReplicationStrategy.setScriptReadOnly | train | public function setScriptReadOnly($script, $readonly = true)
{
$sha1 = sha1($script);
if ($readonly) {
$this->readonlySHA1[$sha1] = $readonly;
} else {
unset($this->readonlySHA1[$sha1]);
}
} | php | {
"resource": ""
} |
q13903 | ReplicationStrategy.getDisallowedOperations | train | protected function getDisallowedOperations()
{
return array(
'SHUTDOWN' => true,
'INFO' => true,
'DBSIZE' => true,
'LASTSAVE' => true,
'CONFIG' => true,
'MONITOR' => true,
'SLAVEOF' => true,
'SAVE' => true,
... | php | {
"resource": ""
} |
q13904 | ReplicationStrategy.getReadOnlyOperations | train | protected function getReadOnlyOperations()
{
return array(
'EXISTS' => true,
'TYPE' => true,
'KEYS' => true,
'SCAN' => true,
'RANDOMKEY' => true,
'TTL' => true,
'GET' => true,
'MGET' => true,
'SUBSTR'... | php | {
"resource": ""
} |
q13905 | Client.createOptions | train | protected function createOptions($options)
{
if (is_array($options)) {
return new Options($options);
}
if ($options instanceof OptionsInterface) {
return $options;
}
throw new \InvalidArgumentException('Invalid type for client options.');
} | php | {
"resource": ""
} |
q13906 | Client.getConnectionById | train | public function getConnectionById($connectionID)
{
if (!$this->connection instanceof AggregateConnectionInterface) {
throw new NotSupportedException(
'Retrieving connections by ID is supported only by aggregate connections.'
);
}
return $this->connect... | php | {
"resource": ""
} |
q13907 | Client.createPipeline | train | protected function createPipeline(array $options = null, $callable = null)
{
if (isset($options['atomic']) && $options['atomic']) {
$class = 'Predis\Pipeline\Atomic';
} elseif (isset($options['fire-and-forget']) && $options['fire-and-forget']) {
$class = 'Predis\Pipeline\Fire... | php | {
"resource": ""
} |
q13908 | Client.createTransaction | train | protected function createTransaction(array $options = null, $callable = null)
{
$transaction = new MultiExecTransaction($this, $options);
if (isset($callable)) {
return $transaction->execute($callable);
}
return $transaction;
} | php | {
"resource": ""
} |
q13909 | ListKey.reset | train | protected function reset()
{
$this->valid = true;
$this->fetchmore = true;
$this->elements = array();
$this->position = -1;
$this->current = null;
} | php | {
"resource": ""
} |
q13910 | ListKey.executeCommand | train | protected function executeCommand()
{
return $this->client->lrange($this->key, $this->position + 1, $this->position + $this->count);
} | php | {
"resource": ""
} |
q13911 | PhpiredisStreamConnection.createReader | train | private function createReader()
{
$reader = phpiredis_reader_create();
phpiredis_reader_set_status_handler($reader, $this->getStatusHandler());
phpiredis_reader_set_error_handler($reader, $this->getErrorHandler());
return $reader;
} | php | {
"resource": ""
} |
q13912 | MasterSlaveReplication.handleInfoResponse | train | private function handleInfoResponse($response)
{
$info = array();
foreach (preg_split('/\r?\n/', $response) as $row) {
if (strpos($row, ':') === false) {
continue;
}
list($k, $v) = explode(':', $row, 2);
$info[$k] = $v;
}
... | php | {
"resource": ""
} |
q13913 | MasterSlaveReplication.discover | train | public function discover()
{
if (!$this->connectionFactory) {
throw new ClientException('Discovery requires a connection factory');
}
RETRY_FETCH: {
try {
if ($connection = $this->getMaster()) {
$this->discoverFromMaster($connectio... | php | {
"resource": ""
} |
q13914 | MasterSlaveReplication.discoverFromMaster | train | protected function discoverFromMaster(NodeConnectionInterface $connection, FactoryInterface $connectionFactory)
{
$response = $connection->executeCommand(RawCommand::create('INFO', 'REPLICATION'));
$replication = $this->handleInfoResponse($response);
if ($replication['role'] !== 'master') {... | php | {
"resource": ""
} |
q13915 | MasterSlaveReplication.discoverFromSlave | train | protected function discoverFromSlave(NodeConnectionInterface $connection, FactoryInterface $connectionFactory)
{
$response = $connection->executeCommand(RawCommand::create('INFO', 'REPLICATION'));
$replication = $this->handleInfoResponse($response);
if ($replication['role'] !== 'slave') {
... | php | {
"resource": ""
} |
q13916 | MasterSlaveReplication.retryCommandOnFailure | train | private function retryCommandOnFailure(CommandInterface $command, $method)
{
RETRY_COMMAND: {
try {
$connection = $this->getConnection($command);
$response = $connection->$method($command);
if ($response instanceof ResponseErrorInterface && $respo... | php | {
"resource": ""
} |
q13917 | AbstractConsumer.subscribe | train | public function subscribe($channel /*, ... */)
{
$this->writeRequest(self::SUBSCRIBE, func_get_args());
$this->statusFlags |= self::STATUS_SUBSCRIBED;
} | php | {
"resource": ""
} |
q13918 | AbstractConsumer.psubscribe | train | public function psubscribe($pattern /* ... */)
{
$this->writeRequest(self::PSUBSCRIBE, func_get_args());
$this->statusFlags |= self::STATUS_PSUBSCRIBED;
} | php | {
"resource": ""
} |
q13919 | AbstractConsumer.stop | train | public function stop($drop = false)
{
if (!$this->valid()) {
return false;
}
if ($drop) {
$this->invalidate();
$this->disconnect();
} else {
if ($this->isFlagSet(self::STATUS_SUBSCRIBED)) {
$this->unsubscribe();
... | php | {
"resource": ""
} |
q13920 | AbstractConsumer.valid | train | public function valid()
{
$isValid = $this->isFlagSet(self::STATUS_VALID);
$subscriptionFlags = self::STATUS_SUBSCRIBED | self::STATUS_PSUBSCRIBED;
$hasSubscriptions = ($this->statusFlags & $subscriptionFlags) > 0;
return $isValid && $hasSubscriptions;
} | php | {
"resource": ""
} |
q13921 | PredisCluster.removeById | train | public function removeById($connectionID)
{
if ($connection = $this->getConnectionById($connectionID)) {
return $this->remove($connection);
}
return false;
} | php | {
"resource": ""
} |
q13922 | PredisCluster.getConnectionByKey | train | public function getConnectionByKey($key)
{
$hash = $this->strategy->getSlotByKey($key);
$node = $this->distributor->getBySlot($hash);
return $node;
} | php | {
"resource": ""
} |
q13923 | PredisCluster.executeCommandOnNodes | train | public function executeCommandOnNodes(CommandInterface $command)
{
$responses = array();
foreach ($this->pool as $connection) {
$responses[] = $connection->executeCommand($command);
}
return $responses;
} | php | {
"resource": ""
} |
q13924 | ServerInfo.parseRow | train | protected function parseRow($row)
{
list($k, $v) = explode(':', $row, 2);
if (preg_match('/^db\d+$/', $k)) {
$v = $this->parseDatabaseStats($v);
}
return array($k, $v);
} | php | {
"resource": ""
} |
q13925 | ServerInfo.parseDatabaseStats | train | protected function parseDatabaseStats($str)
{
$db = array();
foreach (explode(',', $str) as $dbvar) {
list($dbvk, $dbvv) = explode('=', $dbvar);
$db[trim($dbvk)] = $dbvv;
}
return $db;
} | php | {
"resource": ""
} |
q13926 | ServerInfo.parseAllocationStats | train | protected function parseAllocationStats($str)
{
$stats = array();
foreach (explode(',', $str) as $kv) {
@list($size, $objects, $extra) = explode('=', $kv);
// hack to prevent incorrect values when parsing the >=256 key
if (isset($extra)) {
$size ... | php | {
"resource": ""
} |
q13927 | Command.normalizeVariadic | train | public static function normalizeVariadic(array $arguments)
{
if (count($arguments) === 2 && is_array($arguments[1])) {
return array_merge(array($arguments[0]), $arguments[1]);
}
return $arguments;
} | php | {
"resource": ""
} |
q13928 | Parameters.parse | train | public static function parse($uri)
{
if (stripos($uri, 'unix://') === 0) {
// parse_url() can parse unix:/path/to/sock so we do not need the
// unix:///path/to/sock hack, we will support it anyway until 2.0.
$uri = str_ireplace('unix://', 'unix:', $uri);
}
... | php | {
"resource": ""
} |
q13929 | PhpiredisSocketConnection.emitSocketError | train | private function emitSocketError()
{
$errno = socket_last_error();
$errstr = socket_strerror($errno);
$this->disconnect();
$this->onConnectionError(trim($errstr), $errno);
} | php | {
"resource": ""
} |
q13930 | PhpiredisSocketConnection.getAddress | train | protected static function getAddress(ParametersInterface $parameters)
{
if (filter_var($host = $parameters->host, FILTER_VALIDATE_IP)) {
return $host;
}
if ($host === $address = gethostbyname($host)) {
return false;
}
return $address;
} | php | {
"resource": ""
} |
q13931 | PhpiredisSocketConnection.setSocketOptions | train | private function setSocketOptions($socket, ParametersInterface $parameters)
{
if ($parameters->scheme !== 'unix') {
if (!socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1)) {
$this->emitSocketError();
}
if (!socket_set_option($socket, SOL_SOCKET, SO_REUS... | php | {
"resource": ""
} |
q13932 | PhpiredisSocketConnection.connectWithTimeout | train | private function connectWithTimeout($socket, $address, ParametersInterface $parameters)
{
socket_set_nonblock($socket);
if (@socket_connect($socket, $address, (int) $parameters->port) === false) {
$error = socket_last_error();
if ($error != SOCKET_EINPROGRESS && $error != S... | php | {
"resource": ""
} |
q13933 | WebdisConnection.createCurl | train | private function createCurl()
{
$parameters = $this->getParameters();
$timeout = (isset($parameters->timeout) ? (float) $parameters->timeout : 5.0) * 1000;
if (filter_var($host = $parameters->host, FILTER_VALIDATE_IP)) {
$host = "[$host]";
}
$options = array(
... | php | {
"resource": ""
} |
q13934 | MultiExec.assertClient | train | private function assertClient(ClientInterface $client)
{
if ($client->getConnection() instanceof AggregateConnectionInterface) {
throw new NotSupportedException(
'Cannot initialize a MULTI/EXEC transaction over aggregate connections.'
);
}
if (!$clien... | php | {
"resource": ""
} |
q13935 | MultiExec.configure | train | protected function configure(ClientInterface $client, array $options)
{
if (isset($options['exceptions'])) {
$this->exceptions = (bool) $options['exceptions'];
} else {
$this->exceptions = $client->getOptions()->exceptions;
}
if (isset($options['cas'])) {
... | php | {
"resource": ""
} |
q13936 | MultiExec.call | train | protected function call($commandID, array $arguments = array())
{
$response = $this->client->executeCommand(
$this->client->createCommand($commandID, $arguments)
);
if ($response instanceof ErrorResponseInterface) {
throw new ServerException($response->getMessage());... | php | {
"resource": ""
} |
q13937 | MultiExec.watch | train | public function watch($keys)
{
if (!$this->client->getProfile()->supportsCommand('WATCH')) {
throw new NotSupportedException('WATCH is not supported by the current profile.');
}
if ($this->state->isWatchAllowed()) {
throw new ClientException('Sending WATCH after MULT... | php | {
"resource": ""
} |
q13938 | MultiExec.multi | train | public function multi()
{
if ($this->state->check(MultiExecState::INITIALIZED | MultiExecState::CAS)) {
$this->state->unflag(MultiExecState::CAS);
$this->call('MULTI');
} else {
$this->initialize();
}
return $this;
} | php | {
"resource": ""
} |
q13939 | MultiExec.discard | train | public function discard()
{
if ($this->state->isInitialized()) {
$this->call($this->state->isCAS() ? 'UNWATCH' : 'DISCARD');
$this->reset();
$this->state->flag(MultiExecState::DISCARDED);
}
return $this;
} | php | {
"resource": ""
} |
q13940 | MultiExec.checkBeforeExecution | train | private function checkBeforeExecution($callable)
{
if ($this->state->isExecuting()) {
throw new ClientException(
'Cannot invoke "execute" or "exec" inside an active transaction context.'
);
}
if ($callable) {
if (!is_callable($callable)) {... | php | {
"resource": ""
} |
q13941 | MultiExec.executeTransactionBlock | train | protected function executeTransactionBlock($callable)
{
$exception = null;
$this->state->flag(MultiExecState::INSIDEBLOCK);
try {
call_user_func($callable, $this);
} catch (CommunicationException $exception) {
// NOOP
} catch (ServerException $excepti... | php | {
"resource": ""
} |
q13942 | ResponseReader.getDefaultHandlers | train | protected function getDefaultHandlers()
{
return array(
'+' => new Handler\StatusResponse(),
'-' => new Handler\ErrorResponse(),
':' => new Handler\IntegerResponse(),
'$' => new Handler\BulkResponse(),
'*' => new Handler\MultiBulkResponse(),
... | php | {
"resource": ""
} |
q13943 | MultiBulkTuple.checkPreconditions | train | protected function checkPreconditions(MultiBulk $iterator)
{
if ($iterator->getPosition() !== 0) {
throw new \InvalidArgumentException(
'Cannot initialize a tuple iterator using an already initiated iterator.'
);
}
if (($size = count($iterator)) % 2 !... | php | {
"resource": ""
} |
q13944 | CursorBasedIterator.getScanOptions | train | protected function getScanOptions()
{
$options = array();
if (strlen($this->match) > 0) {
$options['MATCH'] = $this->match;
}
if ($this->count > 0) {
$options['COUNT'] = $this->count;
}
return $options;
} | php | {
"resource": ""
} |
q13945 | KeyPrefixProcessor.first | train | public static function first(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
$arguments[0] = "$prefix{$arguments[0]}";
$command->setRawArguments($arguments);
}
} | php | {
"resource": ""
} |
q13946 | KeyPrefixProcessor.interleaved | train | public static function interleaved(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
$length = count($arguments);
for ($i = 0; $i < $length; $i += 2) {
$arguments[$i] = "$prefix{$arguments[$i]}";
}
$command->s... | php | {
"resource": ""
} |
q13947 | KeyPrefixProcessor.sort | train | public static function sort(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
$arguments[0] = "$prefix{$arguments[0]}";
if (($count = count($arguments)) > 1) {
for ($i = 1; $i < $count; ++$i) {
switch (strtoupper($... | php | {
"resource": ""
} |
q13948 | KeyPrefixProcessor.evalKeys | train | public static function evalKeys(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
for ($i = 2; $i < $arguments[1] + 2; ++$i) {
$arguments[$i] = "$prefix{$arguments[$i]}";
}
$command->setRawArguments($arguments);
}
... | php | {
"resource": ""
} |
q13949 | KeyPrefixProcessor.migrate | train | public static function migrate(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
$arguments[2] = "$prefix{$arguments[2]}";
$command->setRawArguments($arguments);
}
} | php | {
"resource": ""
} |
q13950 | KeyPrefixProcessor.georadius | train | public static function georadius(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
$arguments[0] = "$prefix{$arguments[0]}";
$startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;
if (($count = count($arguments)) > $startIndex) {
... | php | {
"resource": ""
} |
q13951 | HashRing.add | train | public function add($node, $weight = null)
{
// In case of collisions in the hashes of the nodes, the node added
// last wins, thus the order in which nodes are added is significant.
$this->nodes[] = array(
'object' => $node,
'weight' => (int) $weight ?: $this::DEFAUL... | php | {
"resource": ""
} |
q13952 | HashRing.initialize | train | private function initialize()
{
if ($this->isInitialized()) {
return;
}
if (!$this->nodes) {
throw new EmptyRingException('Cannot initialize an empty hashring.');
}
$this->ring = array();
$totalWeight = $this->computeTotalWeight();
$n... | php | {
"resource": ""
} |
q13953 | HashRing.addNodeToRing | train | protected function addNodeToRing(&$ring, $node, $totalNodes, $replicas, $weightRatio)
{
$nodeObject = $node['object'];
$nodeHash = $this->getNodeHash($nodeObject);
$replicas = (int) round($weightRatio * $totalNodes * $replicas);
for ($i = 0; $i < $replicas; ++$i) {
$key ... | php | {
"resource": ""
} |
q13954 | AbstractConnection.createExceptionMessage | train | private function createExceptionMessage($message)
{
$parameters = $this->parameters;
if ($parameters->scheme === 'unix') {
return "$message [$parameters->scheme:$parameters->path]";
}
if (filter_var($parameters->host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
... | php | {
"resource": ""
} |
q13955 | AbstractConnection.onConnectionError | train | protected function onConnectionError($message, $code = null)
{
CommunicationException::handle(
new ConnectionException($this, static::createExceptionMessage($message), $code)
);
} | php | {
"resource": ""
} |
q13956 | ServerClient.parseClientList | train | protected function parseClientList($data)
{
$clients = array();
foreach (explode("\n", $data, -1) as $clientData) {
$client = array();
foreach (explode(' ', $clientData) as $kv) {
@list($k, $v) = explode('=', $kv);
$client[$k] = $v;
... | php | {
"resource": ""
} |
q13957 | Pipeline.exception | train | protected function exception(ConnectionInterface $connection, ErrorResponseInterface $response)
{
$connection->disconnect();
$message = $response->getMessage();
throw new ServerException($message);
} | php | {
"resource": ""
} |
q13958 | Pipeline.getConnection | train | protected function getConnection()
{
$connection = $this->getClient()->getConnection();
if ($connection instanceof ReplicationInterface) {
$connection->switchTo('master');
}
return $connection;
} | php | {
"resource": ""
} |
q13959 | Pipeline.executePipeline | train | protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands)
{
foreach ($commands as $command) {
$connection->writeRequest($command);
}
$responses = array();
$exceptions = $this->throwServerExceptions();
while (!$commands->isEmpty()) ... | php | {
"resource": ""
} |
q13960 | Pipeline.flushPipeline | train | public function flushPipeline($send = true)
{
if ($send && !$this->pipeline->isEmpty()) {
$responses = $this->executePipeline($this->getConnection(), $this->pipeline);
$this->responses = array_merge($this->responses, $responses);
} else {
$this->pipeline = new \Sp... | php | {
"resource": ""
} |
q13961 | Pipeline.execute | train | public function execute($callable = null)
{
if ($callable && !is_callable($callable)) {
throw new \InvalidArgumentException('The argument must be a callable object.');
}
$exception = null;
$this->setRunning(true);
try {
if ($callable) {
... | php | {
"resource": ""
} |
q13962 | Handler.register | train | public function register()
{
if (PHP_VERSION_ID >= 50400) {
session_set_save_handler($this, true);
} else {
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this... | php | {
"resource": ""
} |
q13963 | Factory.define | train | public static function define($alias, $class)
{
$reflection = new \ReflectionClass($class);
if (!$reflection->isSubclassOf('Predis\Profile\ProfileInterface')) {
throw new \InvalidArgumentException("The class '$class' is not a valid profile class.");
}
self::$profiles[$a... | php | {
"resource": ""
} |
q13964 | Factory.get | train | public static function get($version)
{
if (!isset(self::$profiles[$version])) {
throw new ClientException("Unknown server profile: '$version'.");
}
$profile = self::$profiles[$version];
return new $profile();
} | php | {
"resource": ""
} |
q13965 | Status.get | train | public static function get($payload)
{
switch ($payload) {
case 'OK':
case 'QUEUED':
if (isset(self::$$payload)) {
return self::$$payload;
}
return self::$$payload = new self($payload);
default:
... | php | {
"resource": ""
} |
q13966 | Factory.checkInitializer | train | protected function checkInitializer($initializer)
{
if (is_callable($initializer)) {
return $initializer;
}
$class = new \ReflectionClass($initializer);
if (!$class->isSubclassOf('Predis\Connection\NodeConnectionInterface')) {
throw new \InvalidArgumentExcep... | php | {
"resource": ""
} |
q13967 | Factory.createParameters | train | protected function createParameters($parameters)
{
if (is_string($parameters)) {
$parameters = Parameters::parse($parameters);
} else {
$parameters = $parameters ?: array();
}
if ($this->defaults) {
$parameters += $this->defaults;
}
... | php | {
"resource": ""
} |
q13968 | Factory.prepareConnection | train | protected function prepareConnection(NodeConnectionInterface $connection)
{
$parameters = $connection->getParameters();
if (isset($parameters->password)) {
$connection->addConnectCommand(
new RawCommand(array('AUTH', $parameters->password))
);
}
... | php | {
"resource": ""
} |
q13969 | StreamConnection.assertSslSupport | train | protected function assertSslSupport(ParametersInterface $parameters)
{
if (
filter_var($parameters->persistent, FILTER_VALIDATE_BOOLEAN) &&
version_compare(PHP_VERSION, '7.0.0beta') < 0
) {
throw new \InvalidArgumentException('Persistent SSL connections require PH... | php | {
"resource": ""
} |
q13970 | StreamConnection.createStreamSocket | train | protected function createStreamSocket(ParametersInterface $parameters, $address, $flags)
{
$timeout = (isset($parameters->timeout) ? (float) $parameters->timeout : 5.0);
if (!$resource = @stream_socket_client($address, $errno, $errstr, $timeout, $flags)) {
$this->onConnectionError(trim(... | php | {
"resource": ""
} |
q13971 | StreamConnection.tcpStreamInitializer | train | protected function tcpStreamInitializer(ParametersInterface $parameters)
{
if (!filter_var($parameters->host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$address = "tcp://$parameters->host:$parameters->port";
} else {
$address = "tcp://[$parameters->host]:$parameters->port";
... | php | {
"resource": ""
} |
q13972 | StreamConnection.unixStreamInitializer | train | protected function unixStreamInitializer(ParametersInterface $parameters)
{
if (!isset($parameters->path)) {
throw new \InvalidArgumentException('Missing UNIX domain socket path.');
}
$flags = STREAM_CLIENT_CONNECT;
if (isset($parameters->persistent)) {
if (... | php | {
"resource": ""
} |
q13973 | StreamConnection.tlsStreamInitializer | train | protected function tlsStreamInitializer(ParametersInterface $parameters)
{
$resource = $this->tcpStreamInitializer($parameters);
$metadata = stream_get_meta_data($resource);
// Detect if crypto mode is already enabled for this stream (PHP >= 7.0.0).
if (isset($metadata['crypto'])) {... | php | {
"resource": ""
} |
q13974 | StreamConnection.write | train | protected function write($buffer)
{
$socket = $this->getResource();
while (($length = strlen($buffer)) > 0) {
$written = @fwrite($socket, $buffer);
if ($length === $written) {
return;
}
if ($written === false || $written === 0) {
... | php | {
"resource": ""
} |
q13975 | RedisCluster.removeById | train | public function removeById($connectionID)
{
if (isset($this->pool[$connectionID])) {
unset(
$this->pool[$connectionID],
$this->slotsMap
);
return true;
}
return false;
} | php | {
"resource": ""
} |
q13976 | RedisCluster.buildSlotsMap | train | public function buildSlotsMap()
{
$this->slotsMap = array();
foreach ($this->pool as $connectionID => $connection) {
$parameters = $connection->getParameters();
if (!isset($parameters->slots)) {
continue;
}
foreach (explode(',', $par... | php | {
"resource": ""
} |
q13977 | RedisCluster.retryCommandOnFailure | train | private function retryCommandOnFailure(CommandInterface $command, $method)
{
$failure = false;
RETRY_COMMAND: {
try {
$response = $this->getConnection($command)->$method($command);
} catch (ConnectionException $exception) {
$connection = $exce... | php | {
"resource": ""
} |
q13978 | ClusterStrategy.setCommandHandler | train | public function setCommandHandler($commandID, $callback = null)
{
$commandID = strtoupper($commandID);
if (!isset($callback)) {
unset($this->commands[$commandID]);
return;
}
if (!is_callable($callback)) {
throw new \InvalidArgumentException(
... | php | {
"resource": ""
} |
q13979 | ClusterStrategy.checkSameSlotForKeys | train | protected function checkSameSlotForKeys(array $keys)
{
if (!$count = count($keys)) {
return false;
}
$currentSlot = $this->getSlotByKey($keys[0]);
for ($i = 1; $i < $count; ++$i) {
$nextSlot = $this->getSlotByKey($keys[$i]);
if ($currentSlot !==... | php | {
"resource": ""
} |
q13980 | SentinelReplication.createSentinelConnection | train | protected function createSentinelConnection($parameters)
{
if ($parameters instanceof NodeConnectionInterface) {
return $parameters;
}
if (is_string($parameters)) {
$parameters = Parameters::parse($parameters);
}
if (is_array($parameters)) {
... | php | {
"resource": ""
} |
q13981 | SentinelReplication.getSentinelConnection | train | public function getSentinelConnection()
{
if (!$this->sentinelConnection) {
if (!$this->sentinels) {
throw new \Predis\ClientException('No sentinel server available for autodiscovery.');
}
$sentinel = array_shift($this->sentinels);
$this->sent... | php | {
"resource": ""
} |
q13982 | SentinelReplication.handleSentinelErrorResponse | train | private function handleSentinelErrorResponse(NodeConnectionInterface $sentinel, ErrorResponseInterface $error)
{
if ($error->getErrorType() === 'IDONTKNOW') {
throw new ConnectionException($sentinel, $error->getMessage());
} else {
throw new ServerException($error->getMessage... | php | {
"resource": ""
} |
q13983 | SentinelReplication.querySentinelForMaster | train | protected function querySentinelForMaster(NodeConnectionInterface $sentinel, $service)
{
$payload = $sentinel->executeCommand(
RawCommand::create('SENTINEL', 'get-master-addr-by-name', $service)
);
if ($payload === null) {
throw new ServerException('ERR No such maste... | php | {
"resource": ""
} |
q13984 | SentinelReplication.querySentinelForSlaves | train | protected function querySentinelForSlaves(NodeConnectionInterface $sentinel, $service)
{
$slaves = array();
$payload = $sentinel->executeCommand(
RawCommand::create('SENTINEL', 'slaves', $service)
);
if ($payload instanceof ErrorResponseInterface) {
$this->h... | php | {
"resource": ""
} |
q13985 | SentinelReplication.getConnectionInternal | train | private function getConnectionInternal(CommandInterface $command)
{
if (!$this->current) {
if ($this->strategy->isReadOperation($command) && $slave = $this->pickSlave()) {
$this->current = $slave;
} else {
$this->current = $this->getMaster();
... | php | {
"resource": ""
} |
q13986 | SentinelReplication.assertConnectionRole | train | protected function assertConnectionRole(NodeConnectionInterface $connection, $role)
{
$role = strtolower($role);
$actualRole = $connection->executeCommand(RawCommand::create('ROLE'));
if ($role !== $actualRole[0]) {
throw new RoleException($connection, "Expected $role but got $a... | php | {
"resource": ""
} |
q13987 | MultiBulk.drop | train | public function drop($disconnect = false)
{
if ($disconnect) {
if ($this->valid()) {
$this->position = $this->size;
$this->connection->disconnect();
}
} else {
while ($this->valid()) {
$this->next();
}
... | php | {
"resource": ""
} |
q13988 | ServerSentinel.processMastersOrSlaves | train | protected static function processMastersOrSlaves(array $servers)
{
foreach ($servers as $idx => $node) {
$processed = array();
$count = count($node);
for ($i = 0; $i < $count; ++$i) {
$processed[$node[$i]] = $node[++$i];
}
$server... | php | {
"resource": ""
} |
q13989 | Consumer.getValue | train | private function getValue()
{
$database = 0;
$client = null;
$event = $this->client->getConnection()->read();
$callback = function ($matches) use (&$database, &$client) {
if (2 === $count = count($matches)) {
// Redis <= 2.4
$database = (i... | php | {
"resource": ""
} |
q13990 | PubSubPubsub.processNumsub | train | protected static function processNumsub(array $channels)
{
$processed = array();
$count = count($channels);
for ($i = 0; $i < $count; ++$i) {
$processed[$channels[$i]] = $channels[++$i];
}
return $processed;
} | php | {
"resource": ""
} |
q13991 | DispatcherLoop.attachCallback | train | public function attachCallback($channel, $callback)
{
$callbackName = $this->getPrefixKeys().$channel;
$this->assertCallback($callback);
$this->callbacks[$callbackName] = $callback;
$this->pubsub->subscribe($channel);
} | php | {
"resource": ""
} |
q13992 | DispatcherLoop.detachCallback | train | public function detachCallback($channel)
{
$callbackName = $this->getPrefixKeys().$channel;
if (isset($this->callbacks[$callbackName])) {
unset($this->callbacks[$callbackName]);
$this->pubsub->unsubscribe($channel);
}
} | php | {
"resource": ""
} |
q13993 | DispatcherLoop.run | train | public function run()
{
foreach ($this->pubsub as $message) {
$kind = $message->kind;
if ($kind !== Consumer::MESSAGE && $kind !== Consumer::PMESSAGE) {
if (isset($this->subscriptionCallback)) {
$callback = $this->subscriptionCallback;
... | php | {
"resource": ""
} |
q13994 | DispatcherLoop.getPrefixKeys | train | protected function getPrefixKeys()
{
$options = $this->pubsub->getClient()->getOptions();
if (isset($options->prefix)) {
return $options->prefix->getPrefix();
}
return '';
} | php | {
"resource": ""
} |
q13995 | Consumer.genericSubscribeInit | train | private function genericSubscribeInit($subscribeAction)
{
if (isset($this->options[$subscribeAction])) {
$this->$subscribeAction($this->options[$subscribeAction]);
}
} | php | {
"resource": ""
} |
q13996 | CommunicationException.handle | train | public static function handle(CommunicationException $exception)
{
if ($exception->shouldResetConnection()) {
$connection = $exception->getConnection();
if ($connection->isConnected()) {
$connection->disconnect();
}
}
throw $exception;
... | php | {
"resource": ""
} |
q13997 | ProfileOption.setProcessors | train | protected function setProcessors(OptionsInterface $options, ProfileInterface $profile)
{
if (isset($options->prefix) && $profile instanceof RedisProfile) {
// NOTE: directly using __get('prefix') is actually a workaround for
// HHVM 2.3.0. It's correct and respects the options interf... | php | {
"resource": ""
} |
q13998 | RedisProfile.getCommandClass | train | public function getCommandClass($commandID)
{
if (isset($this->commands[$commandID = strtoupper($commandID)])) {
return $this->commands[$commandID];
}
} | php | {
"resource": ""
} |
q13999 | RedisProfile.defineCommand | train | public function defineCommand($commandID, $class)
{
$reflection = new \ReflectionClass($class);
if (!$reflection->isSubclassOf('Predis\Command\CommandInterface')) {
throw new \InvalidArgumentException("The class '$class' is not a valid command class.");
}
$this->command... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.