Long sessions ravendb

We are using RavenDB for our site. The site loads all of its data into memory (not so much) to be able to handle massive loads. We load the data into a background thread that regularly checks with DB (RavenDB + sqlserver) if there is any new data and if this loads that data into memory.

We tried a lot of things to get around the annoying 30 requests to RavenDB per session. Since Raven has no mechanism to "reset" the session after we are done with one iteration of the check / load loop, and since there is no way to tell the Structuremap, we really want a new session, even if we are still the same thread as before. we're kind of stuck.

After all, I have a back grill, so our stores now use a RavenSessionProxy for which a mapmap structure is loaded for us, which can be reset in a load / fetch loop (which will introduce new documentation manually when we reset it).

Is this really the only way? Isn't there some mechanism in Raven to say "hey Mr. Session, I'm done with you now, fix yourself and be fresh and ready next time I call you") or tell Structuremap "Hi SM! Next I ask you to get an IDocumentSession, bring me a new one, I'm tired of this old one "

+3


source to share


2 answers


As Ayende noted, sessions should be short-lived. Rather than having your background job depend on the session, should it depend on the IDocumentStore and then create / delete a session for each run. IDocumentStore can be a one-line, inserted into the container at startup.



+4


source


AndreasKnudsen, The RavenDB session is designed for a relatively short circuit. If you need to hold on to them for a while, you are probably doing something wrong. Note that RavenDB is already doing a lot to make sure it is fast, so loading the content into memory is not required.



You can set session.Advanced.MaxNumberOfRequests, which will increase the number of requests you can make, but that also means you will be storing more information in memory.

+1


source







All Articles