Struct RandomAccessCache<TValue>.ReadWriteSession<TKey>
Represents a session that can be used to read or insert the cache record value.
Inherited Members
Namespace: DotNext.Runtime.Caching
Assembly: DotNext.Threading.dll
Syntax
public readonly struct RandomAccessCache<TValue>.ReadWriteSession<TKey> : IDisposable, IAsyncDisposable where TKey : ISupplier<ReadOnlySpan<byte>>
Type Parameters
| Name | Description |
|---|---|
| TKey |
Remarks
If the record exists, the session prevents it from reclamation. Otherwise, the session holds the lock that prevents the concurrent insertion of the record with the same key.
Methods
View SourceDispose()
Closes the session.
Declaration
public void Dispose()
Remarks
This method should be called only once. The method doesn't wait for the cache entry promotion.
DisposeAsync()
Closes the session and waits for the promotion of the inserted entry.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | The task representing asynchronous state of the cache entry promotion. |
Remarks
This method should be called only once.
SetValue(in TValue)
Inserts the cache record value.
Declaration
public void SetValue(in TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value to insert. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The session is invalid; the record already exists; the value is inserted more than once. |
TryGetValue(out TValue)
Tries to get the value of the cache record.
Declaration
public bool TryGetValue(out TValue result)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | result | The value of the cache record. |
Returns
| Type | Description |
|---|---|
| bool |