-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Lazy adapters implementation #183
base: master
Are you sure you want to change the base?
Conversation
Example of lazy adapter for Sphinxsearch engine https://github.com/Koc/Sphinxy/blob/master/Pagerfanta/Adapter/SphinxyQbAdapter.php |
Looks interesting for elasticsearch, too: For example: I need aggregations from PagerfantaAdpter which are the same on all pages. EDIT: Your PR is missing the actual |
|
||
if ($this->adapter instanceof LazyAdapterInterface) { | ||
$page = $this->filterOutOfRangeCurrentPage($this->getCurrentPage()); | ||
if ($page != $this->getCurrentPage()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use a string comparison
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean (string)$page !== (string)$this->getCurrentPage()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
he probably meant strict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I meant strict
@mablae |
Tests have been added |
Unfortunately the problem with double queries is still relevant. |
Use case: some databases/search engines aren't required execute two queries for getting count and slice. So we can use only one query for slice and count, but now it doesn't work properly, because Pagerfanta filters current page so early, before slice query executed.
For preventing +1 query I've created
LazyAdapterInterface
that marks adapter as lazy.TODO: