mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-01 11:17:54 +08:00
fix: use fixed ttl
This commit is contained in:
parent
795199d5df
commit
c4cd77fb0a
@ -78,7 +78,7 @@ class RedisAdapter implements AdapterInterface, EphemeralInterface
|
||||
foreach ($rooms as $room) {
|
||||
$this->redis->sAdd($this->getRoomKey($room), $sid);
|
||||
if ($this->ttl > 0) {
|
||||
$this->redis->zAdd($this->getExpireKey(), (int) (microtime(true) * 1000) + $this->ttl, $sid);
|
||||
$this->redis->zAdd($this->getExpireKey(), microtime(true) * 1000 + $this->ttl, $sid);
|
||||
}
|
||||
}
|
||||
$this->redis->sAdd($this->getStatKey(), $sid);
|
||||
@ -226,7 +226,7 @@ class RedisAdapter implements AdapterInterface, EphemeralInterface
|
||||
public function renew(string $sid): void
|
||||
{
|
||||
if ($this->ttl > 0) {
|
||||
$this->redis->zIncrBy($this->getExpireKey(), $this->ttl, $sid);
|
||||
$this->redis->zAdd($this->getExpireKey(), microtime(true) * 1000 + $this->ttl, $sid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,7 @@ class RoomAdapterTest extends AbstractTestCase
|
||||
$room->setTtl(1);
|
||||
$room->add('renewed', 'foo');
|
||||
$room->renew('renewed');
|
||||
$room->renew('renewed');
|
||||
usleep(1000);
|
||||
usleep(500);
|
||||
$room->cleanUpExpiredOnce();
|
||||
$this->assertContains('renewed', $room->clients('foo'));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user