I'm trying to implement token based paging in my project's API but it doesn't look like the page_state result metadata is exposed by Cassandra\Response\Result. Is there a recommended way to capture this value so my clients can request the next page at a later time?
For now I'm using the following hack to work around this:
$pageState = null;
while (true) {
/** @var Result $res */
$res = $cass->querySync('SELECT "key" FROM message', [], null, ['page_size' => 10, 'paging_state' => $pageState]);
yield from $res->fetchCol();
$pageState = CassandraResultMetadataAccessor::getPageState($res);
if (!$pageState) break;
echo 'DEBUG: paging token for client: ' . base64_encode($pageState) . "\n";
}
class CassandraResultMetadataAccessor extends Result
{
public static function getPageState(Result $res) {
return $res->_metadata['page_state'] ?? null;
}
}
I'm trying to implement token based paging in my project's API but it doesn't look like the
page_stateresult metadata is exposed byCassandra\Response\Result. Is there a recommended way to capture this value so my clients can request the next page at a later time?For now I'm using the following hack to work around this: