Class MemoryShortLivedStore
An IShortLivedStore that keeps values in memory, up to MaxSize.
Implements
Namespace: Singulink.Net.Http.Api.Service
Assembly: Singulink.Net.Http.Api.Service.dll
Syntax
public sealed class MemoryShortLivedStore : IShortLivedStore
Remarks
Values only exist in the process that added them, so the other servers of a service do not see them. A restart loses them, which only interrupts the flows in progress and resets rate limit counts.
When the store is full, adding a value or a counter throws a ServiceUnavailableApiException (see MaxSize).
Constructors
| Name | Description |
|---|---|
| MemoryShortLivedStore(TimeProvider) | Initializes a new instance of the MemoryShortLivedStore class with the default options. |
| MemoryShortLivedStore(TimeProvider, IOptions<MemoryShortLivedStoreOptions>, ILogger<MemoryShortLivedStore>) | Initializes a new instance of the MemoryShortLivedStore class. |
Methods
| Name | Description |
|---|---|
| GetAsync(string, CancellationToken) | Gets the value of a key, or returns null if the key has no value. The value of a counter is its count as decimal text. |
| IncrementAsync(string, long, TimeSpan, CancellationToken) | Adds an amount to the counter under a key and returns the new count. A key without a value counts from 0. Every increment sets the counter to expire after the lifetime, counted from the increment. |
| RemoveAsync(string, CancellationToken) | Removes the value of a key, if it has one. |
| TakeAsync(string, CancellationToken) | Gets and removes the value of a key, or returns null if the key has no value. A value is returned at most once, even when it is taken by concurrent calls. |
| TryAddAsync(string, string, TimeSpan, CancellationToken) | Adds a value under a key unless the key already has a value. |