| @@ 448-473 (lines=26) @@ | ||
| 445 | $this->sendCommand($name, $channels, $opcb); |
|
| 446 | } |
|
| 447 | } |
|
| 448 | elseif ($name === 'UNSUBSCRIBEREAL') { |
|
| 449 | ||
| 450 | /* Race-condition-free UNSUBSCRIBE */ |
|
| 451 | ||
| 452 | $old = $this->subscribeCb; |
|
| 453 | $this->sendCommand('UNSUBSCRIBE', $args, function($redis) use ($cb, $args, $old) { |
|
| 454 | if (!$redis) { |
|
| 455 | call_user_func($cb, $redis); |
|
| 456 | return; |
|
| 457 | } |
|
| 458 | foreach ($args as $arg) { |
|
| 459 | if (!isset($this->subscribeCb[$arg])) { |
|
| 460 | continue; |
|
| 461 | } |
|
| 462 | foreach ($old[$arg] as $oldcb) { |
|
| 463 | CallbackWrapper::removeFromArray($this->subscribeCb[$arg], $oldcb); |
|
| 464 | } |
|
| 465 | if (!sizeof($this->subscribeCb[$arg])) { |
|
| 466 | unset($this->subscribeCb[$arg]); |
|
| 467 | } |
|
| 468 | } |
|
| 469 | if ($cb !== null) { |
|
| 470 | call_user_func($cb, $this); |
|
| 471 | } |
|
| 472 | }); |
|
| 473 | } |
|
| 474 | elseif ($name === 'PUNSUBSCRIBE') { |
|
| 475 | $channels = []; |
|
| 476 | foreach ($args as $arg) { |
|
| @@ 496-521 (lines=26) @@ | ||
| 493 | $this->sendCommand($name, $channels, $opcb); |
|
| 494 | } |
|
| 495 | } |
|
| 496 | elseif ($name === 'PUNSUBSCRIBEREAL') { |
|
| 497 | ||
| 498 | /* Race-condition-free PUNSUBSCRIBE */ |
|
| 499 | ||
| 500 | $old = $this->psubscribeCb; |
|
| 501 | $this->sendCommand('PUNSUBSCRIBE', $args, function($redis) use ($cb, $args, $old) { |
|
| 502 | if (!$redis) { |
|
| 503 | call_user_func($cb, $redis); |
|
| 504 | return; |
|
| 505 | } |
|
| 506 | foreach ($args as $arg) { |
|
| 507 | if (!isset($this->psubscribeCb[$arg])) { |
|
| 508 | continue; |
|
| 509 | } |
|
| 510 | foreach ($old[$arg] as $oldcb) { |
|
| 511 | CallbackWrapper::removeFromArray($this->psubscribeCb[$arg], $oldcb); |
|
| 512 | } |
|
| 513 | if (!sizeof($this->psubscribeCb[$arg])) { |
|
| 514 | unset($this->psubscribeCb[$arg]); |
|
| 515 | } |
|
| 516 | } |
|
| 517 | if ($cb !== null) { |
|
| 518 | call_user_func($cb, $this); |
|
| 519 | } |
|
| 520 | }); |
|
| 521 | } else { |
|
| 522 | if ($name === 'MGET') { |
|
| 523 | $this->resultTypeStack->push(static::RESULT_TYPE_ARGSVALS); |
|
| 524 | $this->argsStack->push($args); |
|