The persistence allow you to store any objects and retrieve thems at the next application launch.

How to Use ?

Method to use in the fluent configuration builder: .UsePersistence()

Basic Example

This simple example show you how to setup persistence.

using (var tdb = new TypeDB.Core(Mode.Standalone)
.UsePersistence(new Persistence
Location = Persistence.TemporaryLocation,
Type = PersistenceType.Snapshot,
Interval = TimeSpan.FromMinutes(1)
var testdb = tdb.OpenDatabase("test", true)
testdb.Set<string>("hello", "world"); // hello entity will be persisted

The Types of Persistence

Type-DB has 3 modes of persistence and the default mode is PersistenceType.Node (no persistence).


This mode not store your entities when you call a specific method otherwise any persistence is executed, for perform a ponctual persistence you need to execute this method:

tdb.Configuration.Persistence.Invoke(tdb); //where 'tdb' is your Instance of Typedb


This mode is pretty useful to store entities regularly in the delay that you want, if you choose this mode you need to configure the interval with a TimeSpan object like this:

Interval = TimeSpan.FromMinutes(1)


This is the most heavy mode because it create a trigger for each method that you will call and perform a physical persistence accordingly.

You can also read about Triggers.

Location of the Persistence

By default Type-DB store all your entities in the Temp folder (on Windows this folder is C:\Users\you\AppData\Local\Temp) but you can choose this folder by setting the Location property:

Location = @"c:\my_folder"

You can also use some constant like:

  • Persistence.TemporaryLocation that is the default OS temp folder

  • Persistence.ApplicationDataLocation that is the AppData folder

  • Persistence.CurrentLocation that return the current execution folder