Jaahas.WriteAheadLog.FileSystem
1.0.0-pre.1
dotnet add package Jaahas.WriteAheadLog.FileSystem --version 1.0.0-pre.1
NuGet\Install-Package Jaahas.WriteAheadLog.FileSystem -Version 1.0.0-pre.1
<PackageReference Include="Jaahas.WriteAheadLog.FileSystem" Version="1.0.0-pre.1" />
<PackageVersion Include="Jaahas.WriteAheadLog.FileSystem" Version="1.0.0-pre.1" />
<PackageReference Include="Jaahas.WriteAheadLog.FileSystem" />
paket add Jaahas.WriteAheadLog.FileSystem --version 1.0.0-pre.1
#r "nuget: Jaahas.WriteAheadLog.FileSystem, 1.0.0-pre.1"
#:package Jaahas.WriteAheadLog.FileSystem@1.0.0-pre.1
#addin nuget:?package=Jaahas.WriteAheadLog.FileSystem&version=1.0.0-pre.1&prerelease
#tool nuget:?package=Jaahas.WriteAheadLog.FileSystem&version=1.0.0-pre.1&prerelease
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 | Versions 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. |
-
net9.0
- Jaahas.WriteAheadLog (>= 1.0.0-pre.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
- Microsoft.Extensions.ObjectPool (>= 9.0.7)
- Microsoft.IO.RecyclableMemoryStream (>= 3.0.1)
- Nito.AsyncEx.Coordination (>= 5.1.2)
- System.IO.Hashing (>= 9.0.7)
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 |