Show / Hide Table of Contents

Struct RandomAccessCache<TValue>.ReadWriteSession<TKey>

Represents a session that can be used to read or insert the cache record value.

Implements
IDisposable
IAsyncDisposable
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<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 Source

Dispose()

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.

View Source

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.

View Source

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.

View Source

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

true if value exists; otherwise, false.

Implements

IDisposable
IAsyncDisposable

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
☀
☾