Show / Hide Table of Contents

Struct RandomAccessCache<TKey, TValue>.ReadWriteSession

Represents a session that can be used to read, modify or promote the cache record value.

Implements
IDisposable
IAsyncDisposable
Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
ValueType.ToString()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: DotNext.Runtime.Caching
Assembly: DotNext.Threading.dll
Syntax
public readonly struct RandomAccessCache<TKey, TValue>.ReadWriteSession : IDisposable, IAsyncDisposable
Remarks

While session alive, the record cannot be evicted.

Properties

| Edit this page View Source

ValueRefOrNullRef

Gets a reference to a value.

Declaration
public ref readonly TValue ValueRefOrNullRef { get; }
Property Value
Type Description
TValue

A reference to a value; or reference.

Methods

| Edit this page 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.

| Edit this page View Source

DisposeAsync()

Closes the session.

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. It's recommended to use this method to ensure that the cache entry is promoted. This is useful when the cache is rate-limited. Otherwise, use Dispose(), because concurrent promotions are handled by the single thread running in the background. Thus, awaiting of the returned task can cause contention over multiple writers.

| Edit this page View Source

SetValue(TValue)

Promotes or modifies the cache record value.

Declaration
public void SetValue(TValue value)
Parameters
Type Name Description
TValue value

The value to promote or replace the existing value.

Exceptions
Type Condition
InvalidOperationException

The session is invalid; the value promotes more than once.

| Edit this page 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, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
ExpressionBuilder.Const<T>(T)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾