views:

510

answers:

2

Hi,

Does anyone have used memcached as a level2 cache or lucene.net for searching with nhibernate ? Can you please share your advances on nhibernate caching & indexing/searching.

And, is memcached (with enyim cilent on the same machine by appserver) the fastest l2cache solution with nhibernate ?

Best Regards sirmak

+2  A: 

We have used Lucene.NET with success to improve the search performance of a several GB's large database. The Lucene.NET result id's are then passed on to NHibernate for fetching. NHibernate queries would time-out, yet Lucene.NET would return the results in a matter of seconds. We haven't used Memcached, so I can't compare both solutions.

The biggest drawback is the fact that the Lucene index has to be kept in sync with the actual database.

Edit: One thing you might want to look at is NHibernate.Search, if you're going to go the Lucene.NET & NHibernate route, it's a project which handles the Lucene index creation & synchronization for you. It has some nice features, last time I checked it made an index per class, indexing all the properties automatically. This wasn't useful for us, since we wanted to index referenced objects as well, but in some cases this should be sufficient. Don't know in which state the project is now, it has been a while since I had a look.

Yannick Compernol
thank you very much
sirmak
+3  A: 

I have used both experimentally. For the second-level-cache i can't compare it with any other option, as it was the only one i used, except perhaps of not having one: It will deliver performance gains immediately, but they will be more noticeable for scenarios where you mostly read than insert/update, when dealing with large datasets and when having a cluster. Specifically for memcached its a sound solution as the application can be run virtually on any kind of machine (like a cheap-o Linux machine)

For Lucene.NET i've used it both vanilla (no nhibernate though, but on production not just experiments) and in the form of NHibernate.Search whereas the integration with nhibernate is seamless: the indexes are generated and manipulated behind the curtain and everything is configured at the Class declaration (unfortunately with class and property attributes, would have preferred on the mapping). Comparing it with Sql-Server's Fulltext Search engine i think it is more maintainable as you don't have to write normal SQL to fetch using the FT Engine, you just use the Criteria mechanism as well as an exposed mechanism for Lucene queries.

Sync'ing with the database is automatically done during update/insert/delete. Performance of the Lucene.NET engine depends both on the cpu/ram configuration of the machine as well as the speed of the storage medium and i find it comparable if not faster than SqlServer's FullText Engine. As a note, NHibernate.Search indexes are simple and each indexed Class has its own index file making development and peeking in the index easier.

Jaguar
thank you
sirmak