CacheExtensions.GetOrCreateAsync 메서드

정의

오버로드

GetOrCreateAsync<TItem>(IMemoryCache, Object, Func<ICacheEntry,Task<TItem>>)

이 키가 있는 경우 이 키와 연결된 값을 비동기적으로 가져오거나, 제공된 키를 사용하여 새 항목을 생성하고, 키를 찾을 수 없는 경우 지정된 팩터리의 값을 생성합니다.

GetOrCreateAsync<TItem>(IMemoryCache, Object, Func<ICacheEntry,Task<TItem>>, MemoryCacheEntryOptions)

GetOrCreateAsync<TItem>(IMemoryCache, Object, Func<ICacheEntry,Task<TItem>>)

Source:
MemoryCacheExtensions.cs
Source:
MemoryCacheExtensions.cs
Source:
MemoryCacheExtensions.cs

이 키가 있는 경우 이 키와 연결된 값을 비동기적으로 가져오거나, 제공된 키를 사용하여 새 항목을 생성하고, 키를 찾을 수 없는 경우 지정된 팩터리의 값을 생성합니다.

public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TItem> ^ GetOrCreateAsync(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, Func<Microsoft::Extensions::Caching::Memory::ICacheEntry ^, System::Threading::Tasks::Task<TItem> ^> ^ factory);
public static System.Threading.Tasks.Task<TItem> GetOrCreateAsync<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, Func<Microsoft.Extensions.Caching.Memory.ICacheEntry,System.Threading.Tasks.Task<TItem>> factory);
public static System.Threading.Tasks.Task<TItem?> GetOrCreateAsync<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, Func<Microsoft.Extensions.Caching.Memory.ICacheEntry,System.Threading.Tasks.Task<TItem>> factory);
static member GetOrCreateAsync : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * Func<Microsoft.Extensions.Caching.Memory.ICacheEntry, System.Threading.Tasks.Task<'Item>> -> System.Threading.Tasks.Task<'Item>
<Extension()>
Public Function GetOrCreateAsync(Of TItem) (cache As IMemoryCache, key As Object, factory As Func(Of ICacheEntry, Task(Of TItem))) As Task(Of TItem)

형식 매개 변수

TItem

가져올 개체의 유형입니다.

매개 변수

cache
IMemoryCache

이 메서드가 IMemoryCache 확장되는 instance.

key
Object

찾거나 만들 항목의 키입니다.

factory
Func<ICacheEntry,Task<TItem>>

키가 캐시에 없는 경우 이 키와 연결된 값을 만드는 팩터리 작업입니다.

반환

Task<TItem>

비동기 작업(operation)을 나타내는 작업(task) 개체입니다.

적용 대상

GetOrCreateAsync<TItem>(IMemoryCache, Object, Func<ICacheEntry,Task<TItem>>, MemoryCacheEntryOptions)

Source:
MemoryCacheExtensions.cs
public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<TItem> ^ GetOrCreateAsync(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, Func<Microsoft::Extensions::Caching::Memory::ICacheEntry ^, System::Threading::Tasks::Task<TItem> ^> ^ factory, Microsoft::Extensions::Caching::Memory::MemoryCacheEntryOptions ^ createOptions);
public static System.Threading.Tasks.Task<TItem?> GetOrCreateAsync<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, Func<Microsoft.Extensions.Caching.Memory.ICacheEntry,System.Threading.Tasks.Task<TItem>> factory, Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions? createOptions);
static member GetOrCreateAsync : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * Func<Microsoft.Extensions.Caching.Memory.ICacheEntry, System.Threading.Tasks.Task<'Item>> * Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions -> System.Threading.Tasks.Task<'Item>
<Extension()>
Public Function GetOrCreateAsync(Of TItem) (cache As IMemoryCache, key As Object, factory As Func(Of ICacheEntry, Task(Of TItem)), createOptions As MemoryCacheEntryOptions) As Task(Of TItem)

형식 매개 변수

TItem

매개 변수

cache
IMemoryCache
key
Object
factory
Func<ICacheEntry,Task<TItem>>
createOptions
MemoryCacheEntryOptions

반환

Task<TItem>

적용 대상