Struct RandomAccessCache<TKey, TValue>.AlternateLookup<TAlternate>
Provides a type that can be used to perform operations on a cache using alternate key representation.
Inherited Members
Namespace: DotNext.Runtime.Caching
Assembly: DotNext.Threading.dll
Syntax
public readonly struct RandomAccessCache<TKey, TValue>.AlternateLookup<TAlternate> where TAlternate : notnull
Type Parameters
| Name | Description |
|---|---|
| TAlternate | The alternate key representation. |
Methods
View SourceChangeAsync(TAlternate, CancellationToken)
Opens a session that can be used to modify the value associated with the key.
Declaration
public ValueTask<RandomAccessCache<TKey, TValue>.ReadWriteSession> ChangeAsync(TAlternate key, CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TAlternate | key | The key of the cache record. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<RandomAccessCache<TKey, TValue>.ReadWriteSession> | The session that can be used to read or modify the cache record. |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |
| ObjectDisposedException | The cache is disposed. |
InvalidateAsync(TAlternate, CancellationToken)
Invalidates the cache record associated with the specified key.
Declaration
public ValueTask<bool> InvalidateAsync(TAlternate key, CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TAlternate | key | The key of the cache record to be removed. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<bool> | true if the cache record associated with |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |
| ObjectDisposedException | The cache is disposed. |
ReplaceAsync(TAlternate, CancellationToken)
Replaces the cache entry associated with the specified alternate key.
Declaration
public ValueTask<RandomAccessCache<TKey, TValue>.ReadWriteSession> ReplaceAsync(TAlternate key, CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TAlternate | key | The key associated with the cache entry. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<RandomAccessCache<TKey, TValue>.ReadWriteSession> | The session that can be used to modify the cache record. |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |
| ObjectDisposedException | The cache is disposed. |
TryRead(TAlternate, out ReadSession)
Tries to read the cached record by using alternative key representation.
Declaration
public bool TryRead(TAlternate key, out RandomAccessCache<TKey, TValue>.ReadSession session)
Parameters
| Type | Name | Description |
|---|---|---|
| TAlternate | key | The key of the cache record. |
| RandomAccessCache<TKey, TValue>.ReadSession | session | A session that can be used to read the cached record. |
Returns
| Type | Description |
|---|---|
| bool | true if the record is available for reading and the session is active; otherwise, false. |
Remarks
The cache guarantees that the value cannot be evicted concurrently with the session. However, the value can be evicted immediately after. The caller must dispose session.
TryRemoveAsync(TAlternate, CancellationToken)
Tries to invalidate cache record associated with the provided key.
Declaration
public ValueTask<RandomAccessCache<TKey, TValue>.ReadSession?> TryRemoveAsync(TAlternate key, CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TAlternate | key | The key of the cache record to be removed. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<RandomAccessCache<TKey, TValue>.ReadSession?> | The session that can be used to read the removed cache record;
or null if there is no record associated with |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |
| ObjectDisposedException | The cache is disposed. |