Jaahas.WriteAheadLog.FileSystem 1.0.0-pre.1

This is a prerelease version of Jaahas.WriteAheadLog.FileSystem.
dotnet add package Jaahas.WriteAheadLog.FileSystem --version 1.0.0-pre.1
                    
NuGet\Install-Package Jaahas.WriteAheadLog.FileSystem -Version 1.0.0-pre.1
                    
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="Jaahas.WriteAheadLog.FileSystem" Version="1.0.0-pre.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jaahas.WriteAheadLog.FileSystem" Version="1.0.0-pre.1" />
                    
Directory.Packages.props
<PackageReference Include="Jaahas.WriteAheadLog.FileSystem" />
                    
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 Jaahas.WriteAheadLog.FileSystem --version 1.0.0-pre.1
                    
#r "nuget: Jaahas.WriteAheadLog.FileSystem, 1.0.0-pre.1"
                    
#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 Jaahas.WriteAheadLog.FileSystem@1.0.0-pre.1
                    
#: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=Jaahas.WriteAheadLog.FileSystem&version=1.0.0-pre.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Jaahas.WriteAheadLog.FileSystem&version=1.0.0-pre.1&prerelease
                    
Install as a Cake Tool

About

Jaahas.WriteAheadLog.FileSystem provides a durable, high-performance file-based implementation of the IWriteAheadLog interface for .NET applications. It is the default storage backend for the Jaahas Write-Ahead Log (WAL) system, supporting reliable, append-only logging with configurable segment rollover and retention policies.

Features

  • Durable, append-only file-based log segments
  • Automatic segment rollover (by size, time, or message count)
  • Configurable retention and cleanup policies
  • High-throughput, low-latency logging
  • Integration with dependency injection

Getting Started

To use the file-based write-ahead log, register it with your application's dependency injection container:

services.AddWriteAheadLogServices().AddFile(options => {
    options.DataDirectory = "data/wal";
});

You can then inject IWriteAheadLog into your components:

var log = serviceProvider.GetRequiredService<IWriteAheadLog>();

Registering Multiple Logs

You can register multiple named logs with different configurations:

services.AddWriteAheadLogServices()
    .AddFile("log-1", options => { options.DataDirectory = "data/wal-1"; })
    .AddFile("log-2", options => { options.DataDirectory = "data/wal-2"; });

Resolve a specific log by name:

var log1 = serviceProvider.GetRequiredKeyedService<IWriteAheadLog>("log-1");

Or use the factory:

var log2 = serviceProvider.GetRequiredService<WriteAheadLogFactory>()
    .GetWriteAheadLog("log-2");

Writing Log Entries

Write entries using the WriteAsync method:

await log.WriteAsync(Encoding.UTF8.GetBytes("Hello, World!"));

Reading Log Entries

Read entries using the ReadAsync method or one of its extension method overloads. You must dispose of each LogEntry instance once no longer needed to release shared resources:

await foreach (var entry in log.ReadAsync()) {
    try {
        var data = Encoding.UTF8.GetString(entry.Data);
        Console.WriteLine(data);
    }
    finally {
        // Dispose of the entry when done to release shared resources
        entry.Dispose();
    }
}

Configuring Rollover and Retention

You can control segment rollover and retention using FileWriteAheadLogOptions:

var options = new FileWriteAheadLogOptions {
    DataDirectory = "data/wal",
    MaxSegmentSizeBytes = 1024 * 1024, // 1 MB
    SegmentRetentionLimit = 100,
    SegmentRetentionPeriod = TimeSpan.FromDays(7),
    SegmentCleanupInterval = TimeSpan.FromHours(12)
};

More Information

Please visit the GitHub repository for advanced usage, including using the LogWriter and JsonLogWriter types for writing log entries, and using the LogReader type for reading log entries and maintaining progress checkpoints.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-pre.1 170 7/13/2025