AsyncMysqlConnection::lastActivityTime
Last time a successful activity was made in the current connection, in seconds since epoch
public function lastActivityTime(): float;
The first successful activity of the current connection is its creation.
Returns
float
- Afloat
representing the number of seconds ago since epoch that we had successful activity on the current connection.
Examples
This example shows how to determine the last time a successful call was made using a given connection via AsyncMysqlConnection::lastActivityTime
. The value returned is seconds since epoch as a float
.
use \Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI;
async function connect(
\AsyncMysqlConnectionPool $pool,
): Awaitable<\AsyncMysqlConnection> {
return await $pool->connect(
CI::$host,
CI::$port,
CI::$db,
CI::$user,
CI::$passwd,
);
}
async function get_time(): Awaitable<float> {
$pool = new \AsyncMysqlConnectionPool(darray[]);
$conn = await connect($pool);
$t = $conn->lastActivityTime();
$conn->close();
return $t;
}
<<__EntryPoint>>
async function run(): Awaitable<void> {
$t = await get_time();
\var_dump($t);
}
```.hhvm.expectf
float(%f)
```.example.hhvm.out
float(17272.084797)
```.skipif
await \Hack\UserDocumentation\API\Examples\AsyncMysql\skipif_async();