[Dbix-class] Caching total_entires in the Pager -- how can build
a good cache key?
Peter Rabbitson
rabbit+dbic at rabbit.us
Fri Aug 9 03:41:34 GMT 2013
On Thu, Aug 08, 2013 at 11:51:47AM -0700, Bill Moseley wrote:
> I have a REST app that returns collections a page at a time. So, part of
> that response is the Data::Page object.
>
> There is some overhead with fetching the total_entires each time I query
> for the next page of results, and in my case it doesn't change frequently.
> So, I'm thinking about caching.
Don't. It won't change frequrently until it does.
Instead bring in the total entries as a subselect via
{ '+columns' => { tot_cnt => $orig_unpaged_rs->count_rs->as_query } }
and use $any_result_obj->get_column('tot_cnt') to populate the pager
tot count.
Cheers
More information about the DBIx-Class
mailing list