CSharpDB.Storage 1.2.0

dotnet add package CSharpDB.Storage --version 1.2.0
                    
NuGet\Install-Package CSharpDB.Storage -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpDB.Storage" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpDB.Storage" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="CSharpDB.Storage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharpDB.Storage --version 1.2.0
                    
#r "nuget: CSharpDB.Storage, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharpDB.Storage@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharpDB.Storage&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=CSharpDB.Storage&version=1.2.0
                    
Install as a Cake Tool

CSharpDB.Storage

B+tree storage engine with page cache, write-ahead log (WAL), crash recovery, and concurrent snapshot-isolated readers for the CSharpDB embedded database engine.

NuGet License: MIT

Overview

CSharpDB.Storage is the disk-level storage layer for CSharpDB. It manages all physical I/O through a page-oriented architecture with B+tree data structures, a write-ahead log for durability, and snapshot isolation for concurrent readers. Single-file storage, zero external dependencies.

Architecture

┌─────────────────────────────┐
│       CatalogService        │  Schema catalog (B+tree-backed)
├─────────────────────────────┤
│          BTree              │  Key-value storage (long -> byte[])
├─────────────────────────────┤
│      Pager + PageCache      │  Page I/O, LRU cache, transactions
├──────────────┬──────────────┤
│  WAL (Write  │  Storage     │  Durability & file I/O
│  Ahead Log)  │  Device      │
└──────────────┴──────────────┘

Key Components

B+Tree

  • Keyed by long rowid with variable-length payloads
  • Leaf-hint cache for fast sequential access
  • Stack allocation for small cells (<=256 bytes), ArrayPool for splits
  • Cursor-based iteration with MoveNextAsync and SeekAsync

Pager

  • 4 KB page-oriented I/O with 100-byte file header
  • LRU page cache with configurable capacity
  • Single-writer transactions via SemaphoreSlim
  • Page allocation and freelist management

Write-Ahead Log (WAL)

  • Append-only log with frame-level checksums
  • Batch commit for multi-page writes
  • Automatic checkpoint with configurable threshold (default: 1000 frames)
  • Crash recovery with salt and checksum validation

Concurrent Access

  • Single writer + multiple concurrent readers
  • Snapshot isolation via WalIndex snapshots
  • WAL backpressure to protect long-running readers
  • TransactionCoordinator with timeout support

Catalog Service

  • B+tree-backed schema storage for tables, indexes, views, and triggers
  • In-memory schema caching with root-page tracking
  • Handles root page updates when B+trees split

Usage

using CSharpDB.Storage;

// Open or create a database file
var options = new StorageEngineOptions { DatabasePath = "mydb.db" };
var context = await StorageEngine.OpenAsync(options);

// Access the pager for page-level operations
var pager = context.Pager;
await pager.BeginTransactionAsync();

// Create a B+tree
var tree = await BTree.CreateNewAsync(pager);

// Insert data
await tree.InsertAsync(1, recordBytes);

// Read data
var data = await tree.FindAsync(1);

// Iterate with a cursor
var cursor = tree.CreateCursor();
while (await cursor.MoveNextAsync())
{
    var key = cursor.CurrentKey;
    var value = cursor.CurrentValue;
}

await pager.CommitAsync();

Page Layout

File:   [Header:100][Page0:4096][Page1:4096][Page2:4096]...
Page:   [PageHeader:9][CellPointers:2*N][  free  ][cells←]
WAL:    [WalHeader:32][Frame:24+4096][Frame:24+4096]...

Installation

dotnet add package CSharpDB.Storage

Dependencies

  • CSharpDB.Core - shared type system and schema definitions
Package Description
CSharpDB.Engine Embedded database engine built on this storage layer
CSharpDB.Storage.Diagnostics Read-only inspection and integrity checking
CSharpDB.Execution Query operators that read/write through this layer

License

MIT - see LICENSE for details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on CSharpDB.Storage:

Package Downloads
CSharpDB.Engine

Lightweight embedded SQL database engine for .NET. Single-file storage, WAL durability, concurrent readers, and a typed Collection<T> NoSQL API.

CSharpDB.Execution

Query planner, operator tree, and expression evaluator for the CSharpDB embedded database.

CSharpDB.Storage.Diagnostics

Read-only storage diagnostics toolkit for CSharpDB database and WAL files.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 0 3/5/2026
1.1.0 51 3/4/2026
1.0.0 73 3/1/2026