how to cache query when using paginator

        $builder = $this->modelsManager->createBuilder();

        $paginator = new QueryBuilderPaginator([
            'builder' => $builder,
            'limit' => $limit,
            'page' => $page,

        $page = $paginator->getPaginate();

two queries will be executed, one for total count , one for items.

is there some ways to cache the queries ?


usually i use something like

'cache' => [
    'key' => 'my-results-page-'.$page

While 2 queries are being executed, I don't believe they're the same query. The query to get the items stores the total rows in SQL_CALC_ROWS, and the second query just retrieves that: . So you're not doing the full, expensive query both times, and caching wouldn't have any affect.