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, andISessionInMemoryDatabasemodel cache scopes.InMemoryDatabaseFactorycreates global or session stores.IInMemoryQueue,IQueueItem,QueueInfo, andWorkStatesupport async queues with leasing, completion, retry, fail, dead-letter, save, load, and diagnostics.InMemoryQueueFactoryprovides access to the configured queue.IInMemoryDatabaseProviderenables alternative backing providers.InMemoryPermissionCacheInvalidatorimplementsIEltheonPermissionCacheInvalidatorfor the legacyUserPermissionstable.- The feature-owned
/Admin/InMemory/IndexRazor 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.