Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return current Unix timestamp
<?php time(): int
<?php public function __invoke()
{
foreach ($this->timerTable as $workerId => $row) {
if ((time() - $row['time']) > $this->maxExecutionTime) {
$this->timerTable->del($workerId);
$this->extension->dispatchProcessSignal($row['worker_pid'], SIGKILL);
<?php $this->extension->dispatchProcessSignal($processId, SIGTERM);
if ($wait) {
$start = time();
do {
if (! $this->canCommunicateWith($processId)) {
<?php $this->extension->dispatchProcessSignal($processId, SIGTERM);
sleep(1);
} while (time() < $start + $wait);
}
return false;
<?php public function sendResponseHeaders(Response $response, SwooleResponse $swooleResponse): void
{
if (! $response->headers->has('Date')) {
$response->setDate(DateTime::createFromFormat('U', time()));
}
$headers = $response->headers->allPreserveCase();
<?php $table['fake-worker-id'] = [
'worker_pid' => 111,
'time' => time() - 60,
];
$action = new EnsureRequestsDontExceedMaxExecutionTime(
<?php $cache = Mockery::mock('stdClass'), Mockery::mock(ExceptionHandler::class)
);
$cache->shouldReceive('get')->with('tick-key')->andReturn(time() - 100);
$cache->shouldReceive('forever')->once()->with('tick-key', $now->getTimestamp());
<?php $cache = Mockery::mock('stdClass'), Mockery::mock(ExceptionHandler::class)
);
$cache->shouldReceive('get')->with('tick-key')->andReturn(time() - 10);
$cache->shouldReceive('forever')->never();
<?php {
$table = $this->createSwooleTable();
$table->set('foo', ['value' => serialize('bar'), 'expiration' => time() + 100]);
$store = new OctaneStore($table);
<?php $store = new OctaneStore($table);
$table->set('foo', ['value' => serialize('bar'), 'expiration' => time() - 100]);
$this->assertNull($store->get('foo'));
}
<?php {
$table = $this->createSwooleTable();
$table->set('foo', ['value' => serialize('bar'), 'expiration' => time() + 100]);
$table->set('bar', ['value' => serialize('baz'), 'expiration' => time() + 100]);
$store = new OctaneStore($table);
<?php $table = $this->createSwooleTable();
$table->set('foo', ['value' => serialize('bar'), 'expiration' => time() + 100]);
$table->set('bar', ['value' => serialize('baz'), 'expiration' => time() + 100]);
$store = new OctaneStore($table);