Method Lease(string, TimeSpan?, CancellationToken)

Assembly: redb.Route.Core.dll

that also names the claim it took: identifies this claim of
the key, so that and
act on it only while it is still the one held. A holder
that outlived abandonedAfter and was taken over then confirms or removes nothing of the new
holder's claim.

The default answers without a token, and the token methods then act on the key as
and do.

public Task<IdempotentLease> Lease(string key, TimeSpan? abandonedAfter, CancellationToken ct = default)

Remarks

The token is a new random id kept in the entry's .
Answered from the entry's and .
An abandoned claim is taken over by deleting the entry that was read, by its object id, and inserting a new one: a
caller that read the same stale entry deletes nothing that is new (its delete finds no object, or its insert loses
on ValueUnique) and answers . Inside an ambient transaction both run
on the transaction's connection, as does.

The age is against this node's clock, so
abandonedAfter must stay far above the clock skew between nodes. An insert that waits on locks
for longer than a tenth of abandonedAfter is stamped again before it commits: a claim stamped
before such a wait would look abandoned the moment it became visible, and another node would take it over.