CSharpDB.Storage
1.8.0
Prefix Reserved
dotnet add package CSharpDB.Storage --version 1.8.0
NuGet\Install-Package CSharpDB.Storage -Version 1.8.0
<PackageReference Include="CSharpDB.Storage" Version="1.8.0" />
<PackageVersion Include="CSharpDB.Storage" Version="1.8.0" />
<PackageReference Include="CSharpDB.Storage" />
paket add CSharpDB.Storage --version 1.8.0
#r "nuget: CSharpDB.Storage, 1.8.0"
#:package CSharpDB.Storage@1.8.0
#addin nuget:?package=CSharpDB.Storage&version=1.8.0
#tool nuget:?package=CSharpDB.Storage&version=1.8.0
CSharpDB.Storage
CSharpDB.Storage is the page-oriented durability layer used by the CSharpDB embedded database engine. It owns:
- physical file I/O through
IStorageDevice - page caching and dirty tracking through
Pager - write-ahead logging and crash recovery through
WriteAheadLog - row-id keyed B+trees for table and index storage
- schema metadata persistence through
SchemaCatalog
This package is usually consumed indirectly through CSharpDB.Engine, but it also supports direct low-level use for tooling, diagnostics, and storage experiments.
Most users: configure storage through Database
If you are using SQL or the engine layer, customize storage like this:
using CSharpDB.Engine;
var options = new DatabaseOptions()
.ConfigureStorageEngine(builder =>
{
builder.UseLookupOptimizedPreset();
});
await using var db = await Database.OpenAsync("app.cdb", options);
UseLookupOptimizedPreset() is the current recommended opt-in preset for file-backed lookup-heavy workloads. It sets MaxCachedPages = 2048 and keeps the standard B-tree index provider, which outperformed the caching index wrapper in the current tuning matrix.
For sustained durable writes, use the write-heavy preset instead:
using CSharpDB.Engine;
var options = new DatabaseOptions()
.ConfigureStorageEngine(builder =>
{
builder.UseWriteOptimizedPreset();
});
await using var db = await Database.OpenAsync("ingest.cdb", options);
UseWriteOptimizedPreset() is the current recommended opt-in preset for file-backed write-heavy workloads. It keeps the existing cache and index configuration, raises the auto-checkpoint frame threshold to 4096, and runs auto-checkpoints in background slices instead of blocking the triggering commit. PagerOptions.AutoCheckpointMaxPagesPerStep controls how much work each background slice performs; the default remains 64 pages. In the current durable-write diagnostics, the 64-page background preset was the best measured background variant at 33.30K ops/sec, slightly ahead of 256 pages at 33.24K and foreground FrameCount(4096) at 33.13K. The important difference is that background sliced mode kept checkpoint work off essentially all commits while the foreground policy still had 246 commits pay checkpoint cost in the median run.
Low-level use: open the storage graph directly
If you need direct access to Pager, SchemaCatalog, or BTree, use the default storage engine factory:
using CSharpDB.Storage.BTrees;
using CSharpDB.Storage.Paging;
using CSharpDB.Storage.StorageEngine;
var storageOptions = new StorageEngineOptionsBuilder()
.UsePagerOptions(new PagerOptions { MaxCachedPages = 1024 })
.UseBTreeIndexes()
.Build();
var factory = new DefaultStorageEngineFactory();
var context = await factory.OpenAsync("lowlevel.cdb", storageOptions);
await using var pager = context.Pager;
await pager.BeginTransactionAsync();
try
{
uint rootPageId = await BTree.CreateNewAsync(pager);
var tree = new BTree(pager, rootPageId);
await tree.InsertAsync(1, new byte[] { 1, 2, 3, 4 });
byte[]? payload = await tree.FindAsync(1);
await pager.CommitAsync();
}
catch
{
await pager.RollbackAsync();
throw;
}
Key extension points
IStorageDevicefor alternate storage backendsIPageCachethroughPagerOptions.PageCacheFactoryICheckpointPolicyfor auto-checkpoint decisionsIPageOperationInterceptorfor diagnostics and fault injectionIPageChecksumProviderfor WAL checksum behaviorIIndexProviderfor index-store compositionISerializerProviderfor record and schema serializationICatalogStorefor catalog payload encodingIStorageEngineFactoryfor replacing the default storage composition root
Related docs
Related packages
| Package | Description |
|---|---|
| CSharpDB.Engine | SQL/engine layer built on this storage package |
| CSharpDB.Storage.Diagnostics | Read-only inspection and integrity tooling |
| CSharpDB.Execution | Query execution layer that reads/writes through storage |
Installation
dotnet add package CSharpDB.Storage
For the all-in-one package:
dotnet add package CSharpDB
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- CSharpDB.Primitives (>= 1.8.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on CSharpDB.Storage:
| Package | Downloads |
|---|---|
|
CSharpDB.Execution
Query planner, operator tree, and expression evaluator for the CSharpDB embedded database. |
|
|
CSharpDB.Engine
Lightweight embedded SQL database engine for .NET. Single-file storage, WAL durability, concurrent readers, and a typed Collection<T> NoSQL API. |
|
|
CSharpDB.Storage.Diagnostics
Read-only storage diagnostics toolkit for CSharpDB database and WAL files. |
|
|
CSharpDB
All-in-one package for CSharpDB application development. Includes the unified client, engine, ADO.NET provider, service layer, and diagnostics. |
GitHub repositories
This package is not used by any popular GitHub repositories.