Documentation
Table of Contents

Class InMemoryMappingStore

Namespace
IntentSharp.Mapping
Assembly
IntentSharp.dll

A mapping store in this process's memory: the rows and the replacement cap are lost when the process ends and are not shared with other processes. It holds at most a set number of keys; storing a new key in a full store removes the key used least recently, with every revision of it and its replacement cap. Rows are copied in and out, so a row a caller holds never changes the stored one. Thread-safe.

public sealed class InMemoryMappingStore : IMappingStore
Inheritance
object
InMemoryMappingStore
Implements
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Extension Methods

Constructors

InMemoryMappingStore(int)

Creates an empty store that holds at most capacity keys, with the system clock for the replacement cap's windows.

InMemoryMappingStore(int, TimeProvider)

Creates an empty store that holds at most capacity keys, with timeProvider for the replacement cap's windows and the retirement times.

Methods

ActivateAsync(string, string, int, MappingRetiredReason, CancellationToken)

In one transaction: retires the active revision of the key, if there is one, with reason and makes the pending revision active. Returns the active row.

AddIfAbsentAsync(CompiledMapping, CancellationToken)

First writer wins: when the key has no active revision, stores mapping as the next revision (1 for a new key) with the status Active. Returns the active row: this one, or the one another writer stored first.

AddPendingAsync(CompiledMapping, CancellationToken)

Stores pending as the next revision with the status Pending and leaves the active revision as it is, for a replacement held until someone activates it. Returns the row as stored.

GetActiveAsync(string, string, CancellationToken)

The active revision of a key, or null when the key has none. A retired or pending revision is never returned.

ListAsync(string, CancellationToken)

Every revision of every key in the namespace, retired and pending ones included, ordered by key (ordinal) and then revision.

ReplaceAsync(CompiledMapping, MappingRetiredReason, CompiledMapping, CancellationToken)

In one transaction: retires retiring with reason only if that revision is still active, and then stores replacement as the next revision with the status Active. When another writer replaced retiring first, nothing is written and that writer's row is returned; when the key has no active revision at all, replacement is stored as the active one. Returns the active row.

RetireAsync(string, string, int, MappingRetiredReason, CancellationToken)

Retires an active or pending revision with reason, for example a stored row the library refused. Returns true when the revision was active or pending and is now retired, false when it does not exist or was retired already.

TryTakeRecompileAsync(string, string, int, TimeSpan, CancellationToken)

The persisted per-key cap on replacements, shared by every process on the store: takes one of limit slots in the current window of length window, which starts at the first slot taken after the previous window ended. Returns true when a slot was taken, false when the window's slots are used up or limit is 0 or less.