EmbeddableDocumentStore with RavenFS In-Memory

67 views
Skip to first unread message

Tobi

unread,
Jul 25, 2016, 7:39:56 AM7/25/16
to RavenDB - 2nd generation document database
How can I create an EmbeddableDocumentStore with a RavenFS running on
in-memory storage for unit tests?

I've tried the following code, but the RavenFS will still be created on
disk:

using (var store = new EmbeddableDocumentStore
{
Configuration =
{
RunInMemory = true,
FileSystemName = "Attachments",
},
UseEmbeddedHttpServer = true
})
{
store.Initialize();
store.ServerIfEmbedded.FilesStore.DefaultFileSystem = "Attachments";
await
store.FilesStore.AsyncFilesCommands.Admin.CreateOrUpdateFileSystemAsync(new
FileSystemDocument
{
Id = "Raven/FileSystem/Attachments",
}, "Attachments");

// Create file
using (var asyncFilesSession =
store.FilesStore.OpenAsyncSession("Attachments"))
{
asyncFilesSession.RegisterUpload("test.txt",
new MemoryStream(Encoding.ASCII.GetBytes("Hello World!")));
Task.Run(async () => await
asyncFilesSession.SaveChangesAsync()).Wait();
}

Grisha Kotler

unread,
Jul 26, 2016, 9:01:44 AM7/26/16
to rav...@googlegroups.com
Inherit from RavenFilesTestBase and use NewStore:

using (var store = NewStore())
{
            store.DefaultFileSystem = "Attachments";
            .....
}

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Grisha Kotler l RavenDB Core Team Developer Mobile: +972-54-586-8647

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/




--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tobi

unread,
Jul 26, 2016, 9:11:20 AM7/26/16
to rav...@googlegroups.com
Seems the FileStore gets created with an Esent storage by default in
the below case. Setting it explicitly to Voron with:

Configuration =
{
RunInMemory = true,
FileSystemName = "Attachments",
FileSystem =
{
DefaultStorageTypeName = "voron"
}
},

...fixes the issue and FileStore now is truly in-memory.

I think FileStore should work exactly like the document store setup and
choose voron by default if RunInMemory is set.

See this lazy PR:

https://github.com/ayende/ravendb/pull/4084

Tobias

Tobi

unread,
Jul 26, 2016, 9:16:15 AM7/26/16
to rav...@googlegroups.com
I can't do this with the integration-tests for my application.

See my other mail - found a solution.

Tobias

Am 26.07.2016 um 15:01 schrieb Grisha Kotler:

> Inherit from RavenFilesTestBase and use NewStore:
>
> using (var store = NewStore())
> {
> store.DefaultFileSystem = "Attachments";
> .....
> }
>
> */Hibernating Rhinos Ltd /*cid:image0...@01CF95E2.8ED1B7D0____
>
> Grisha Kotler* l RavenDB Core Team Developer l *Mobile: +972-54-586-8647__
>
> Office: +972-4-622-7811* l *Fax: +972-153-4-622-7811
>
> */Raven/**/DB/*/ paving the way to "Data Made Simple" http://ravendb.net//
>
>
> On 25 July 2016 at 14:39, Tobi <lista...@e-tobi.net
> <mailto:ravendb%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ravendb+u...@googlegroups.com
> <mailto:ravendb+u...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages