![]() |
VOOZH | about |
dotnet add package BTDB --version 35.2.0
NuGet\Install-Package BTDB -Version 35.2.0
<PackageReference Include="BTDB" Version="35.2.0" />
<PackageVersion Include="BTDB" Version="35.2.0" />Directory.Packages.props
<PackageReference Include="BTDB" />Project file
paket add BTDB --version 35.2.0
#r "nuget: BTDB, 35.2.0"
#:package BTDB@35.2.0
#addin nuget:?package=BTDB&version=35.2.0Install as a Cake Addin
#tool nuget:?package=BTDB&version=35.2.0Install as a Cake Tool
Currently this project these parts:
All code written in C# 12 and licensed under very permissive MIT license. Targeting .Net 9.0, main code has just 2 dependencies (Microsoft.Extensions.Primitives, Microsoft.Extensions.ObjectPool). Code is tested using xUnit Framework. Used in production on Windows and Linux, on MacOS works as well. Please is you find it useful or have questions, write me e-mail so I know that it is used. It is available in Nuget http://www.nuget.org/packages/BTDB. Source code drops are Github releases.
BTDB IOC can be used directly, or it can be bridged into Microsoft.Extensions.DependencyInjection.
There are three distinct modes: standalone BTDB IOC, BTDB IOC with fallback into services registered through
ContainerBuilder.ServiceCollection, and full bidirectional BTDB ↔ ASP.NET DI integration via UseBtdbIoc(...).
For ASP.NET Core Minimal API, register BTDB services into ContainerBuilder and then call UseBtdbIoc(...).
After that, BTDB registrations are available as normal endpoint parameters, and BTDB IContainer can also resolve
services that WebApplication registers automatically.
If you need the BTDB root container from the ASP.NET root IServiceProvider, resolve IRootContainer; plain
IContainer stays scope-bound.
using BTDB;
using BTDB.IOC;
var builder = WebApplication.CreateBuilder(args);
var btdb = new ContainerBuilder();
btdb.RegisterType<MyService>().As<IMyService>().SingleInstance();
builder.Services.UseBtdbIoc(btdb);
var app = builder.Build();
app.MapGet("/",
(IMyService service) => service.Hello());
app.MapGet("/env",
(IContainer container) => container.Resolve<IHostEnvironment>().EnvironmentName);
app.Run();
[Generate]
public interface IMyService
{
string Hello();
}
public class MyService : IMyService
{
readonly IHostEnvironment _environment;
public MyService(IHostEnvironment environment)
{
_environment = environment;
}
public string Hello() => $"Hello from BTDB IOC in {_environment.EnvironmentName}";
}
Removed method RelationInfo.GetProperties(Type type) which was used a long time ago to support so-called "apart fields". It returns an empty list, so it should be easy to remove.
Nearly all IKeyValueDBTransaction methods moved into IKeyValueDBCursor. IKeyValueDBTransaction has method
CreateCursor() to create IKeyValueDBCursor. Created cursor must not be used after transaction Commit. And all
cursors must be disposed before transaction is disposed. It makes implementation of custom transaction wrappers more
difficult, look at KeyValueDBTransactionWithCount for example.
Positive breaking change is that DB could be modified in parallel to enumeration. It is possible due to KeyValueDB has
now Cursors which correctly update their position even when DB is modified. It is even possible to delete current object
in enumeration and enumeration will still continue correctly.
Relations cannot return IEnumerator<T> anymore, it must be replaced by IEnumerable<T>. Also
IOrderedDictionaryEnumerator is now inherited from IDisposable and must be disposed. Forgetting dispose will cause
exception during transaction disposal.
using (var fileCollection = new InMemoryFileCollection())
using (IKeyValueDB db = new KeyValueDB(fileCollection))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(new byte[] { 1 }, new byte[100000]);
tr.Commit();
}
}
When using BTDB.AzureStorage, wait for FlushPendingChangesAsync() before allowing the process to exit. This makes
sure queued transaction log appends are uploaded before a newly created key index file can point at them.
In Kubernetes or AKS, this works only if the container receives SIGTERM and terminationGracePeriodSeconds is long
enough for the flush to finish before the pod is force-killed.
This is about draining the remote Azure Blob upload queue. It does not preserve the local cache directory, which is
typically an emptyDir volume and should be expected to disappear after pod shutdown.
using System.Runtime.InteropServices;
using Azure.Storage.Blobs;
using BTDB.AzureStorage;
using BTDB.KVDBLayer;
var containerClient = new BlobContainerClient(connectionString, "btdb");
await using var fileCollection = await AzureBlobFileCollection.CreateAsync(new AzureBlobFileCollectionOptions
{
BlobStorageBackend = new AzureBlobStorageBackend(containerClient, "tenant-a/prod"),
TransactionLogFlushPeriod = TimeSpan.FromSeconds(30)
});
using var db = new BTreeKeyValueDB(fileCollection);
var shutdown = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
using var sigterm = PosixSignalRegistration.Create(PosixSignal.SIGTERM, _ =>
{
shutdown.TrySetResult();
});
await shutdown.Task;
await fileCollection.FlushPendingChangesAsync();
This help you to write fluent code which generates IL code in runtime. It is used in Object Database part.
var method = ILBuilder.Instance.NewMethod<Func<Nested>>("SampleCall");
var il = method.Generator;
var local = il.DeclareLocal(typeof(Nested), "n");
il
.Newobj(() => new Nested())
.Dup()
.Stloc(local)
.Ldstr("Test")
.Call(() => ((Nested)null).Fun(""))
.Ldloc(local)
.Ret();
var action = method.Create();
Documentation: [https://github.com/Bobris/BTDB/blob/master/Doc/ODBDictionary.md]
Relations doc: [https://github.com/Bobris/BTDB/blob/master/Doc/Relations.md]
public class Person
{
public string Name { get; set; }
public uint Age { get; set; }
}
using (var tr = _db.StartTransaction())
{
tr.Store(new Person { Name = "Bobris", Age = 35 });
tr.Commit();
}
using (var tr = _db.StartTransaction())
{
var p = tr.Enumerate<Person>().First();
Assert.AreEqual("Bobris", p.Name);
Assert.AreEqual(35, p.Age);
}
Bon Binary object notation is allows creating and reading JavaScript/C# values with extensions like Dictionary/Map
into binary notation. It is much faster to parse, write, skip, search by keys than JSON, size will be also smaller in
most cases, in some cases much more smaller.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on BTDB:
| Package | Downloads |
|---|---|
|
Bbcore.Lib
Package Description |
|
|
BTDB.AzureStorage
Azure Blob Storage helpers for BTDB local-cache-backed file collections. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 35.2.0 | 244 | 6/7/2026 |
| 35.1.1 | 319 | 6/3/2026 |
| 35.1.0 | 289 | 5/28/2026 |
| 35.0.5 | 750 | 4/15/2026 |
| 35.0.4 | 179 | 4/15/2026 |
| 35.0.3 | 181 | 4/14/2026 |
| 35.0.2 | 202 | 4/7/2026 |
| 35.0.1 | 178 | 4/7/2026 |
| 35.0.0 | 191 | 4/6/2026 |
| 34.5.1 | 183 | 3/30/2026 |
| 34.5.0 | 174 | 3/30/2026 |
| 34.4.2 | 189 | 3/23/2026 |
| 34.4.1 | 178 | 3/23/2026 |
| 34.4.0 | 172 | 3/20/2026 |
| 33.6.15 | 3,860 | 6/7/2026 |
| 33.6.14 | 94 | 6/7/2026 |
| 33.6.13 | 24,943 | 4/7/2026 |
| 33.6.12 | 3,350 | 3/28/2026 |
| 33.6.11 | 174 | 3/27/2026 |
| 33.6.10 | 171 | 3/24/2026 |