How can I run RavenDB in a shared hosting environment?
Asked Answered
D

1

26

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?

Disabled answered 9/8, 2010 at 21:23 Comment(6)
It depends on the permissions your hosting environment allows... Embedded version in an ASP.Net hosted environmentDivider
Thanks - that covers the second part of my question (i.e. dependencies), but what about a best practice for actually implementing it?Disabled
The download ravendb.net/tutorials contains an MVC sample and the google group is an active community where I am sure you can find answers to specifics.Divider
If you're hosting on AppHarbor, then that platform now has a cloud-hosted, high-performance RavenDB add-on from RavenHQ.Presbyterian
Yeah I saw that this morning. Was going to add an answer myself, but you beat me to it. Thanks.Disabled
With shared hosting, can you access Raven Studio? If so, how do you protect it from public access?Metropolitan
D
13

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.

Dittany answered 4/12, 2011 at 16:45 Comment(2)
You could try use the UseEmbeddedHttpServer = true on the returnStore for the management studio -> ravendb.net/faq/embedded-with-httpCountermove
@David: fantastic... I've been searching for this all day. Running RavenDB in Medium Trust is a pain and currently I think it's not possible. WinHost offers Full Trust! Great. Just what I need.Evangelical

© 2022 - 2024 — McMap. All rights reserved.