NuGet ยท nuget

Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory

Core Feature InMemory for Eltheon Framework

Install

Install-Kommandos

dotnet add package Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory --version 0.9.2.9
<PackageReference Include="Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory" Version="0.9.2.9" />
paket add Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory --version 0.9.2.9
Install-Package Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory -Version 0.9.2.9

README

Vorschau

Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory

In-memory storage and queue feature for Eltheon. It provides scoped and global key/value stores, queue primitives, providers, factories, and optional permission-cache invalidation support.

This package is no longer required by EventCore. Events now owns its local outbox internally. InMemory remains the feature for host-level memory stores, diagnostics, queues, search indexes, email queues, webhook state, and legacy permission cache storage.

Install

dotnet add package Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.InMemory

Components

  • IInMemoryDatabase, IGlobalInMemoryDatabase, and ISessionInMemoryDatabase model cache scopes.
  • InMemoryDatabaseFactory creates global or session stores.
  • IInMemoryQueue, IQueueItem, QueueInfo, and WorkState support async queues with leasing, completion, retry, fail, dead-letter, save, load, and diagnostics.
  • InMemoryQueueFactory provides access to the configured queue.
  • IInMemoryDatabaseProvider enables alternative backing providers.
  • InMemoryPermissionCacheInvalidator implements IEltheonPermissionCacheInvalidator for the legacy UserPermissions table.
  • The feature-owned /Admin/InMemory/Index Razor Class Library page exposes diagnostics and table clearing.

DI Setup

builder.Services.Configure<InMemoryOptions>(configuration.GetSection("InMemory"));
builder.Services.AddSingleton<IInMemoryDatabaseProvider, InProcessInMemoryProvider>();
builder.Services.AddSingleton<InMemoryDatabaseFactory>();
builder.Services.AddSingleton<IInMemoryQueue, InMemoryQueue>();
builder.Services.AddSingleton<InMemoryQueueFactory>();
builder.Services.AddEltheonInMemory();

For Razor Page discovery in hosts:

builder.Services.AddRazorPages()
    .AddEltheonInMemoryApplicationPart();

Configuration:

"InMemory": {
  "Provider": "InProcess",
  "ConnectionString": ""
}

The built-in Redis and Memcached providers are placeholders. Register a real provider implementation before selecting those provider names.

Admin View

The InMemory admin page is packaged in this feature as a Pattern-A Razor Class Library surface. It uses System.InMemory.View for read access and System.InMemory.Clear for clearing tables. Existing legacy permissions such as InMemoryManagement can remain in host seeds for compatibility, but new navigation and page protection should use the typed permissions from this package.

Durable Queue Workflow

var item = await queue.TryLeaseAsync<MyQueueItem>("WorkQueue", cancellationToken);
if (item is null)
{
    return;
}

try
{
    await ProcessAsync(item, cancellationToken);
    await queue.CompleteAsync("WorkQueue", item.QueueInfo.Id);
}
catch (Exception ex)
{
    await queue.RetryAsync("WorkQueue", item.QueueInfo.Id, ex.Message);
}

TryLeaseAsync marks pending or retry items as running without removing them. CompleteAsync removes successful items. RetryAsync, FailAsync, and DeadLetterAsync preserve item state and append queue history. RecoverRunningAsync moves abandoned running items back to retry state after restart.

Persistence

Queues and databases can be persisted through SaveQueuesAsync() and LoadQueuesAsync(). Queue JSON is written through a temporary file and then moved into place. Corrupt queue files are quarantined with a .corrupt.*.bak suffix and the queue starts empty rather than overwriting the damaged file.

DequeueAsync is a wait-for-work primitive, not a polling API. Cancel it during host shutdown.

Permission Cache Invalidation

AddEltheonInMemory() registers InMemoryPermissionCacheInvalidator as an IEltheonPermissionCacheInvalidator. The Permissions feature can call this neutral port after permission changes without depending on InMemory directly.

Diagnostics

Use queue history and GetAllItems() to inspect work state, retry count, last error, and dead-letter items. Wrap IInMemoryQueue or IInMemoryDatabaseProvider with decorators when host-specific metrics are required.