Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (82 sloc) 2.78 KB
description
Type-DB is made to meet the needs of any developer whether for an embedded project, to implement a cache system, or simply when you need a cool database, it is certain that you will love his modularit

Overview of Type-DB

Key-Object Concept instead of Key-Value

The Core Concept of Type-DB is to replace the old concept of KeyValue dictionnaries with a new KeyObject system, that allows you to store any .Net Objects directly into a Type-DB Instance (see Standalone or Remote Mode)

Basic Usage

If you need a simple C# snippet to understand what is Type-DB, take a look here:

{% code-tabs %} {% code-tabs-item title="basic-example.cs" %}

using (var tdb = new TypeDB.Core(Mode.Standalone).Connect())
using (var db = tdb.OpenDatabase("test", true))
{
    db.Set<int>("NumberOfCars", 28);
    var numberOfCars = db.Get<int>("NumberOfCars");
    Console.WriteLine(numberOfCars);
}

{% endcode-tabs-item %} {% endcode-tabs %}

Standalone or Remote Mode

Two operating modes are available on Type-DB, the Standalone mode that does not require the use of a server, which is very convenient for embedded projects, and the Remote mode that is coupled with a Type-DB Server.

Using Example in a Remote Mode:

{% code-tabs %} {% code-tabs-item title="remote-mode-example.cs" %}

var tdb = new TypeDB.Core(TypeDB.Mode.Remote)
.Configure(new TypeDB.Configuration
{
    Endpoint = new Endpoint("localhost", 7000)
})
.Connect();

{% endcode-tabs-item %} {% endcode-tabs %}

{% page-ref page="type-db.server/overview-of-type-db.server.md" %}

Complete Example

{% code-tabs %} {% code-tabs-item title="complete-example.cs" %}

using (var tdb = new TypeDB.Core(Mode.Standalone)
.Configure(new Configuration
{
})
.UsePersistence(new Persistence
{
    Type = PersistenceType.OnlyInvoke,                        
    Location = TypeDB.Persistence.TemporaryLocation,
    // ChunkSize = 10,
    Interval = TimeSpan.FromMinutes(1)
})
// .UseReplication()
// .UseTriggers()
// .UseAuthentication()
// .UseEncryption()
// .UseQuotas()
.Connect())
using (var testdb = tdb.OpenDatabase("test", true))
{
    testdb.Set<int>("clint", 29);
    testdb.Set<int>("quentin", 22);
    testdb.Set<int>("bob", 48);
    testdb.Set("players", "elena", "anything you want");
    testdb.Expire("bob", TimeSpan.FromMinutes(10));
    testdb.Increment("clint", 1);
    testdb.Lock("bob");
    // testdb.Unlock("bob");
    testdb.Drop("bob");

    var newAge = testdb.Get<int>("clint");
    Console.WriteLine(newAge);

    testdb.PrintAll();

    // var backup = testdb.Save();
    // Console.WriteLine(backup);

}

{% endcode-tabs-item %} {% endcode-tabs %}

{% embed url="https://github.com/Type-DB/Core/tree/master/Type-DB.Core.Samples" %}

You can’t perform that action at this time.