Soenneker.Zelos.Suite
3.0.22
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Zelos.Suite --version 3.0.22
NuGet\Install-Package Soenneker.Zelos.Suite -Version 3.0.22
<PackageReference Include="Soenneker.Zelos.Suite" Version="3.0.22" />
paket add Soenneker.Zelos.Suite --version 3.0.22
#r "nuget: Soenneker.Zelos.Suite, 3.0.22"
// Install Soenneker.Zelos.Suite as a Cake Addin #addin nuget:?package=Soenneker.Zelos.Suite&version=3.0.22 // Install Soenneker.Zelos.Suite as a Cake Tool #tool nuget:?package=Soenneker.Zelos.Suite&version=3.0.22
Soenneker.Zelos.Suite
The file-based JSON document database engine
What is Zelos?
Zelos is a lightweight, embedded data store for .NET applications. It leverages JSON for persistent storage while maintaining an in-memory cache for rapid data access. With asynchronous, thread-safe operations, Zelos minimizes I/O overhead by periodically saving only modified containers.
Key Benefits & Features
- Embedded & Minimalistic: Operates without the overhead of an external database server.
- Responsive Asynchronous I/O: Uses async operations to keep your application fast and non-blocking.
- Robust Concurrency: Employs asynchronous locks and semaphores to manage thread safety.
- Container Organization: Segregate your data logically using named containers.
- Efficient Persistence: Automatically saves only when necessary to reduce disk IO.
- Resource Management: Designed to automatically dispose resources when no longer needed, ensuring clean shutdowns.
- Repository Pattern Integration: Streamlines CRUD operations with a familiar design pattern.
Architecture & Components
ZelosDatabase
- Core engine managing the persistence layer.
- Loads or creates the database file on startup.
- Periodically saves dirty containers.
- Manages container initialization and data consistency.
ZelosContainer
& IZelosContainerUtil
ZelosContainer:
- Represents an in-memory container for key/value pairs (stored as JSON).
- Handles adding, updating, and deleting items, marking itself as “dirty” for periodic saves.
IZelosContainerUtil:
- Usage: Retrieves containers by combining the database file path and container name.
- Caching & Creation: Manages container lifecycle, ensuring each container is only loaded once.
ZelosRepository
- Provides a higher-level abstraction using the repository pattern.
- Exposes common CRUD operations for generic document types.
- Uses
IZelosContainerUtil
internally to obtain the right container. - Integrates logging and configuration for detailed diagnostics.
Installation
dotnet add package Soenneker.Zelos.Suite
and then register it:
services.AddZelosSuiteAsSingleton();
Zelos User Management Example
This guide demonstrates how to build a simple user management system using Zelos. The example includes:
- UserDocument: A data model representing a user.
- UsersRepository: Inherits from
ZelosRepository<UserDocument>
. - UserManager: Injects the repository to perform CRUD operations.
Step 1: Define the User Document
Create a UserDocument
class that represents the user data model. This class should inherit from your base Document
class.
using Soenneker.Documents.Document;
public class UserDocument : Document
{
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
Step 2: Create the Users Repository
Create an interface (IUsersRepository
) for user-specific operations. Then, implement this interface in a class UsersRepository
that inherits from ZelosRepository<UserDocument>
. The repository will set the database file path and container name (in this case, "users"
).
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Soenneker.Zelos.Repository;
using Soenneker.Zelos.Container.Util.Abstract;
public class UsersRepository : IZelosRepository<UserDocument>
{
public UsersRepository(IConfiguration configuration, ILogger<UsersRepository> logger,
IZelosContainerUtil containerUtil) : base(configuration, logger, containerUtil)
{
// Set the database file path and container name
DatabaseFilePath = "data/zelos.db";
ContainerName = "users";
}
}
Step 3: Create the User Manager
Create a UserManager
class that injects UsersRepository
to perform operations. In this class, add a new user, update it, and then delete it.
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
public class UserManager
{
private readonly IUsersRepository _usersRepository;
private readonly ILogger<UserManager> _logger;
public UserManager(IUsersRepository usersRepository, ILogger<UserManager> logger)
{
_usersRepository = usersRepository;
_logger = logger;
}
public async Task Execute(CancellationToken cancellationToken = default)
{
// Create a new user document.
var user = new UserDocument
{
Id = Guid.NewGuid().ToString(),
Name = "John Doe",
Email = "john@example.com"
};
_logger.LogInformation("Adding user with Id: {UserId}", user.Id);
await _usersRepository.AddItem(user, cancellationToken);
// Update the user.
user.Email = "john.doe@example.com";
_logger.LogInformation("Updating user with Id: {UserId}", user.Id);
await _usersRepository.UpdateItem(user, cancellationToken);
// Delete the user.
_logger.LogInformation("Deleting user with Id: {UserId}", user.Id);
await _usersRepository.DeleteItem(user.Id, cancellationToken);
}
}
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. |
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Soenneker.Zelos.Repository (>= 3.0.23)
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 |
---|---|---|
3.0.32 | 0 | 2/22/2025 |
3.0.31 | 0 | 2/22/2025 |
3.0.30 | 0 | 2/22/2025 |
3.0.29 | 0 | 2/22/2025 |
3.0.28 | 0 | 2/22/2025 |
3.0.27 | 0 | 2/22/2025 |
3.0.26 | 0 | 2/22/2025 |
3.0.25 | 0 | 2/22/2025 |
3.0.24 | 0 | 2/22/2025 |
3.0.23 | 0 | 2/22/2025 |
3.0.22 | 0 | 2/21/2025 |
3.0.21 | 1 | 2/21/2025 |
3.0.20 | 31 | 2/21/2025 |
3.0.19 | 31 | 2/21/2025 |
3.0.18 | 28 | 2/21/2025 |
3.0.17 | 50 | 2/20/2025 |
3.0.16 | 41 | 2/19/2025 |
3.0.15 | 50 | 2/19/2025 |
3.0.14 | 44 | 2/19/2025 |
3.0.13 | 41 | 2/19/2025 |
3.0.12 | 36 | 2/19/2025 |
3.0.11 | 41 | 2/19/2025 |
3.0.10 | 40 | 2/19/2025 |
3.0.9 | 39 | 2/19/2025 |
3.0.8 | 39 | 2/19/2025 |
3.0.7 | 38 | 2/18/2025 |
3.0.6 | 42 | 2/18/2025 |
3.0.5 | 39 | 2/18/2025 |
3.0.4 | 46 | 2/17/2025 |
3.0.3 | 39 | 2/17/2025 |
3.0.2 | 39 | 2/17/2025 |
3.0.1 | 36 | 2/17/2025 |