CacheExtensions.GetOrCreate Método

Definição

Sobrecargas

GetOrCreate<TItem>(IMemoryCache, Object, Func<ICacheEntry,TItem>)

Obtém o valor associado a essa chave se ela existir ou gera uma nova entrada usando a chave fornecida e um valor da fábrica especificada se a chave não for encontrada.

GetOrCreate<TItem>(IMemoryCache, Object, Func<ICacheEntry,TItem>, MemoryCacheEntryOptions)

GetOrCreate<TItem>(IMemoryCache, Object, Func<ICacheEntry,TItem>)

Obtém o valor associado a essa chave se ela existir ou gera uma nova entrada usando a chave fornecida e um valor da fábrica especificada se a chave não for encontrada.

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

Parâmetros de tipo

TItem

O tipo do objeto a ser obtido.

Parâmetros

cache
IMemoryCache

A IMemoryCache instância que este método estende.

key
Object

A chave da entrada a ser pesquisada ou criada.

factory
Func<ICacheEntry,TItem>

A fábrica que cria o valor associado a essa chave se a chave não existir no cache.

Retornos

TItem

O valor associado a essa chave.

Aplica-se a

GetOrCreate<TItem>(IMemoryCache, Object, Func<ICacheEntry,TItem>, MemoryCacheEntryOptions)

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

Parâmetros de tipo

TItem

Parâmetros

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

Retornos

TItem

Aplica-se a