| @@ 435-460 (lines=26) @@ | ||
| 432 | $this->sendCommand($name, $channels, $opcb); |
|
| 433 | } |
|
| 434 | } |
|
| 435 | elseif ($name === 'UNSUBSCRIBEREAL') { |
|
| 436 | ||
| 437 | /* Race-condition-free UNSUBSCRIBE */ |
|
| 438 | ||
| 439 | $old = $this->subscribeCb; |
|
| 440 | $this->sendCommand('UNSUBSCRIBE', $args, function($redis) use ($cb, $args, $old) { |
|
| 441 | if (!$redis) { |
|
| 442 | call_user_func($cb, $redis); |
|
| 443 | return; |
|
| 444 | } |
|
| 445 | foreach ($args as $arg) { |
|
| 446 | if (!isset($this->subscribeCb[$arg])) { |
|
| 447 | continue; |
|
| 448 | } |
|
| 449 | foreach ($old[$arg] as $oldcb) { |
|
| 450 | CallbackWrapper::removeFromArray($this->subscribeCb[$arg], $oldcb); |
|
| 451 | } |
|
| 452 | if (!sizeof($this->subscribeCb[$arg])) { |
|
| 453 | unset($this->subscribeCb[$arg]); |
|
| 454 | } |
|
| 455 | } |
|
| 456 | if ($cb !== null) { |
|
| 457 | call_user_func($cb, $this); |
|
| 458 | } |
|
| 459 | }); |
|
| 460 | } |
|
| 461 | elseif ($name === 'PUNSUBSCRIBE') { |
|
| 462 | $channels = []; |
|
| 463 | foreach ($args as $arg) { |
|
| @@ 483-508 (lines=26) @@ | ||
| 480 | $this->sendCommand($name, $channels, $opcb); |
|
| 481 | } |
|
| 482 | } |
|
| 483 | elseif ($name === 'PUNSUBSCRIBEREAL') { |
|
| 484 | ||
| 485 | /* Race-condition-free PUNSUBSCRIBE */ |
|
| 486 | ||
| 487 | $old = $this->psubscribeCb; |
|
| 488 | $this->sendCommand('PUNSUBSCRIBE', $args, function($redis) use ($cb, $args, $old) { |
|
| 489 | if (!$redis) { |
|
| 490 | call_user_func($cb, $redis); |
|
| 491 | return; |
|
| 492 | } |
|
| 493 | foreach ($args as $arg) { |
|
| 494 | if (!isset($this->psubscribeCb[$arg])) { |
|
| 495 | continue; |
|
| 496 | } |
|
| 497 | foreach ($old[$arg] as $oldcb) { |
|
| 498 | CallbackWrapper::removeFromArray($this->psubscribeCb[$arg], $oldcb); |
|
| 499 | } |
|
| 500 | if (!sizeof($this->psubscribeCb[$arg])) { |
|
| 501 | unset($this->psubscribeCb[$arg]); |
|
| 502 | } |
|
| 503 | } |
|
| 504 | if ($cb !== null) { |
|
| 505 | call_user_func($cb, $this); |
|
| 506 | } |
|
| 507 | }); |
|
| 508 | } else { |
|
| 509 | if ($name === 'MGET') { |
|
| 510 | $this->resultTypeStack->push(static::RESULT_TYPE_ARGSVALS); |
|
| 511 | $this->argsStack->push($args); |
|