Table of Contents

Class RetentionWorker

Namespace
CL.MySQL2.Services
Assembly
CL.MySQL2.dll

Background worker that purges old rows from entities marked with RetainDaysAttribute. Runs once per 24 hours; on first start it runs after a short delay so library startup isn't blocked by a potentially long delete.

Each purge pass runs DELETE FROM {table} WHERE {col} < NOW() - INTERVAL N DAY LIMIT batchSize repeatedly until a pass deletes zero rows. That keeps individual transactions small (friendly to InnoDB's undo log) while still converging on empty.

public sealed class RetentionWorker : IAsyncDisposable
Inheritance
RetentionWorker
Implements
Inherited Members

Constructors

RetentionWorker(ConnectionManager, ILogger?, IEnumerable<Type>, string)

public RetentionWorker(ConnectionManager connectionManager, ILogger? logger, IEnumerable<Type> registeredEntities, string connectionId = "Default")

Parameters

connectionManager ConnectionManager
logger ILogger
registeredEntities IEnumerable<Type>
connectionId string

Properties

HasWork

Whether any registered entity has a retention policy to run.

public bool HasWork { get; }

Property Value

bool

Methods

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

Start()

public void Start()