Udostępnij za pośrednictwem


ICacheService.TryGetItemAsync Method

Definition

Overloads

TryGetItemAsync(CacheItemKey, PipeWriter, CancellationToken)

Tries to retrieve an item from cache that is assigned to a particular key.

TryGetItemAsync(CacheItemKey, PipeWriter, Boolean, CancellationToken)

Tries to retrieve an item from cache that is assigned to a particular key.

TryGetItemAsync(CacheItemKey, PipeWriter, CancellationToken)

Tries to retrieve an item from cache that is assigned to a particular key.

public:
 System::Threading::Tasks::Task<bool> ^ TryGetItemAsync(Microsoft::VisualStudio::RpcContracts::Caching::CacheItemKey key, System::IO::Pipelines::PipeWriter ^ writer, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<bool> TryGetItemAsync (Microsoft.VisualStudio.RpcContracts.Caching.CacheItemKey key, System.IO.Pipelines.PipeWriter writer, System.Threading.CancellationToken cancellationToken);
abstract member TryGetItemAsync : Microsoft.VisualStudio.RpcContracts.Caching.CacheItemKey * System.IO.Pipelines.PipeWriter * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Public Function TryGetItemAsync (key As CacheItemKey, writer As PipeWriter, cancellationToken As CancellationToken) As Task(Of Boolean)

Parameters

key
CacheItemKey

The key of the value to access.

writer
PipeWriter

Writer to use to stream content.

cancellationToken
CancellationToken

Cancellation token to monitor.

Returns

true if entry is found and data is streamed to writer, false otherwise.

Exceptions

Thrown if cancellationToken is cancelled.

Thrown if this instance has already been disposed.

Thrown when the operation cannot be completed due to a failure in cache storage access.

Remarks

When the service is acquired with the CacheService descriptor or later, this method will not return values that were downloaded from another machine. Use the TryGetItemAsync(CacheItemKey, PipeWriter, Boolean, CancellationToken) overload to allow or explicitly disallow sharing.

Applies to

TryGetItemAsync(CacheItemKey, PipeWriter, Boolean, CancellationToken)

Tries to retrieve an item from cache that is assigned to a particular key.

public System.Threading.Tasks.Task<bool> TryGetItemAsync (Microsoft.VisualStudio.RpcContracts.Caching.CacheItemKey key, System.IO.Pipelines.PipeWriter writer, bool shareable, System.Threading.CancellationToken cancellationToken);
abstract member TryGetItemAsync : Microsoft.VisualStudio.RpcContracts.Caching.CacheItemKey * System.IO.Pipelines.PipeWriter * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Public Function TryGetItemAsync (key As CacheItemKey, writer As PipeWriter, shareable As Boolean, cancellationToken As CancellationToken) As Task(Of Boolean)

Parameters

key
CacheItemKey

The key of the value to access.

writer
PipeWriter

Writer to use to stream content.

shareable
Boolean

A value indicating whether the value is allowed or expected to have come from another machine.

cancellationToken
CancellationToken

Cancellation token to monitor.

Returns

true if entry is found and data is streamed to writer, false otherwise.

Exceptions

Thrown if cancellationToken is cancelled.

Thrown if this instance has already been disposed.

Thrown when the operation cannot be completed due to a failure in cache storage access.

Remarks

This method overload was added in Visual Studio 2022 Update 2.

Applies to