Show / Hide Table of Contents

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
ValueType.Equals(object)
ValueType.GetHashCode()
ValueType.ToString()
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
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 Source

ChangeAsync(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.

View Source

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 key is removed successfully; otherwise, false.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The cache is disposed.

View Source

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.

View Source

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.

View Source

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 key.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The cache is disposed.

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾