amatsuda/kaminari — pull request #495 by aptx4869 (2014-01-16 10:23:21+00:00)
Title: Add support for mongoid max_scan option

When we have a lot of records, for example, more then 20k topics. We can paginate them in a index page, 48 topics for each page, and then there would be about 400 pages. But in practice user does not need that many pages, most people will stop before reaching 20th page.

So I this is a reason good enougth to support the `max_scan` option in mongoid which tells mongodb to query records not more than specific count

This patch also cache the total_count result to avoid generating identical query when we read the pagination info in same controller action

```
MOPED: 127.0.0.1:27017 COMMAND database=staging command={:count=>"u", :query=>{}} runtime: 0.3679ms
MOPED: 127.0.0.1:27017 COMMAND database=staging command={:count=>"u", :query=>{}} runtime: 0.2494ms
MOPED: 127.0.0.1:27017 COMMAND database=staging command={:count=>"u", :query=>{}} runtime: 0.2818ms
```