RavenDB has the ability to run in 'embedded' mode, which as far as I understand, should allow it to be run in a shared hosting environment.
Does anyone have any idea how it would work in an ASP.NET MVC application, and what the best practice for doing it would be?
Are there any dependencies in the hosting environment that I need to be aware of?
Yes.
I have RavenDB running in a shared hosting environment, http://www.winhost.com/, using ASP.NET MVC 3 and RavenDB 1.0.0.371 which was released somewhere around July 2011.
My code:
public static class Store
{
private static IDocumentStore store = createStore();
private static EmbeddableDocumentStore createStore()
{
var returnStore = new EmbeddableDocumentStore();
returnStore.DataDirectory = @"./PersistedData";
returnStore.Initialize();
return returnStore;
}
public static xxx Read(string key)
{
using (var session = store.OpenSession())
{
var anEntity = session.Query<xxx>().
Where(item => item.key == key).Single();
return anEntity;
}
}
public static void Write(xxx)
{
using (var session = store.OpenSession())
{
session.Store(xxx);
session.SaveChanges();
}
}
}
The only downside so far is I don't get the RavenDB management studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With