Class UserGrantCache
- Namespace
- MailFathom.Application.Access.Grants
- Assembly
- MailFathom.Application.dll
The grants this replica computed, kept until something they were computed from may have changed.
public sealed class UserGrantCache
- Inheritance
-
UserGrantCache
- Inherited Members
Remarks
One replica's memory and nothing more. It is a bound on how often a grant is read rather than a guarantee about what a grant is, so it is forgotten whole on every announced change and on every interval of the convergence worker, and a replica that forgot early only reads PostgreSQL once more.
Forgetting is a generation rather than only a clear, because a read can be in flight across it: a grant read before a change committed and remembered after the cache was cleared would otherwise outlive the change it predates. A grant is remembered under the generation that was current when its read began and recalled only while that generation still is.
Properties
- Generation
Gets the generation a read beginning now remembers its grant under.
Methods
- Forget()
Forgets every grant, including one whose read is still in flight.
- Remember(UserId, ScopedGrant, long)
Remembers the grant one read computed.
- TryRecall(UserId, out ScopedGrant?)
Recalls the grant this replica computed for one user, where nothing has been forgotten since.