Skip to content
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

add support for caching #14

Closed
Cliffus opened this issue Sep 9, 2015 · 14 comments
Closed

add support for caching #14

Cliffus opened this issue Sep 9, 2015 · 14 comments

Comments

@Cliffus
Copy link

Cliffus commented Sep 9, 2015

This is more like a feature request than an issue, but it would be great if this library would support caching. Now the library runs a select query for every hit the lucene search engine returns. Caching the results of these queries would be a huge speed improvement.

What do you think?

@nqxcode
Copy link
Owner

nqxcode commented Sep 10, 2015

It will be very useful. I certainly will implement support for caching.

@Cliffus
Copy link
Author

Cliffus commented Sep 10, 2015

great! thanks a lot

@nqxcode nqxcode closed this as completed Oct 18, 2015
@Cliffus
Copy link
Author

Cliffus commented Oct 31, 2015

thanks for fixing my issues! when are you going to release a new version for using it with laravel?

@nqxcode
Copy link
Owner

nqxcode commented Oct 31, 2015

Now each search result is cached, also count of queries in getting limited results is reduced. These improvements are available in version 1.2.* for laravel 4.2.

@Cliffus
Copy link
Author

Cliffus commented Nov 1, 2015

I'm already using laravel 5.1, any idea when it will be also available?

@nqxcode
Copy link
Owner

nqxcode commented Nov 1, 2015

I will try to make necessary changes for laravel 5.0 and 5.1 next week.

@Cliffus
Copy link
Author

Cliffus commented Nov 1, 2015

great, thanks a lot

@nqxcode
Copy link
Owner

nqxcode commented Nov 5, 2015

All improvements are already ported. Try v2.1.2.* for laravel 5.1.

@Cliffus
Copy link
Author

Cliffus commented Nov 9, 2015

thank you very much, I'll try them asap

@Cliffus
Copy link
Author

Cliffus commented Nov 10, 2015

can you summarise the changes I have to implement to make use of the caching? or is this caching used automagically?

@nqxcode
Copy link
Owner

nqxcode commented Nov 12, 2015

There is one large change: new filtering of models. In SearchableInterface: isSearchable has been replaced on getSearchableIds(). Caching for results (in memory, as array) is enabled by default.

There are any troubles?

@Cliffus
Copy link
Author

Cliffus commented Nov 12, 2015

well, I have a database with +/- 75000 rows in it, and Lucene only searches the name field. I didn't implement the SearchableInterface, because all items need to be searchable.

I noticed with Laravel debug bar, that the laravel-lucene-search bundle still queries all item id's from the database and the Nqxcode\LuceneSearch\Model\Config->models() method checks if the hits are also in the id's array. Maybe it makes more sense to skip this check when a model class doesn't implement the SearchableInterface interface? I forked this repo and tried it out:

  • memory usage before: +/- 280 MB, after +/- 8MB
  • I also had a speed gain of +/- 1.5 seconds in page load time

@nqxcode
Copy link
Owner

nqxcode commented Nov 12, 2015

You can speed up getting of results if you do not select all results, you should get results in parts (use paginate() or limit() & get() ).

In Nqxcode\LuceneSearch\Model\Config->models() method, filtering of nonexistent hits (or passing only allowed hits which were obtained by getSearchableIds) is executed.

If you will disable this filtering, the found results will be incorrect. In results there can be not existing models. You will receive unessential acceleration, but the logic of getting results will be broken.

@nqxcode
Copy link
Owner

nqxcode commented Nov 14, 2015

I made some improvements for get() function (show d2a6155 commit), pull them to yourself.

@nqxcode nqxcode reopened this Nov 14, 2015
@nqxcode nqxcode closed this as completed Jan 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants