HybridCache.GetOrCreateAsync Method    
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| GetOrCreateAsync<T>(ReadOnlySpan<Char>, Func<CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken) | 
						 Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.  | 
        	
| GetOrCreateAsync<T>(DefaultInterpolatedStringHandler, Func<CancellationToken, ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken) | 
						 Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.  | 
        	
| GetOrCreateAsync<T>(String, Func<CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken) | 
						 Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.  | 
        	
| GetOrCreateAsync<TState,T>(ReadOnlySpan<Char>, TState, Func<TState, CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken) | 
						 Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.  | 
        	
| GetOrCreateAsync<TState,T>(DefaultInterpolatedStringHandler, TState, Func<TState,CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken) | 
						 Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.  | 
        	
| GetOrCreateAsync<TState,T>(String, TState, Func<TState,CancellationToken, ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken) | 
						 Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.  | 
        	
GetOrCreateAsync<T>(ReadOnlySpan<Char>, Func<CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken)
- Source:
 - HybridCache.cs
 
Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.
public System.Threading.Tasks.ValueTask<T> GetOrCreateAsync<T>(ReadOnlySpan<char> key, Func<System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<T>> factory, Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions? options = default, System.Collections.Generic.IEnumerable<string>? tags = default, System.Threading.CancellationToken cancellationToken = default);
	member this.GetOrCreateAsync : ReadOnlySpan<char> * Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
	Public Function GetOrCreateAsync(Of T) (key As ReadOnlySpan(Of Char), factory As Func(Of CancellationToken, ValueTask(Of T)), Optional options As HybridCacheEntryOptions = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
    Type Parameters
- T
 
The type of the data being considered.
Parameters
- key
 - ReadOnlySpan<Char>
 
The key of the entry to look for or create.
- factory
 - Func<CancellationToken,ValueTask<T>>
 
Provides the underlying data service if the data is not available in the cache.
- options
 - HybridCacheEntryOptions
 
Additional options for this cache entry.
- tags
 - IEnumerable<String>
 
The tags to associate with this cache item.
- cancellationToken
 - CancellationToken
 
The CancellationToken used to propagate notifications that the operation should be canceled.
Returns
The data, either from cache or the underlying data service.
Applies to
GetOrCreateAsync<T>(DefaultInterpolatedStringHandler, Func<CancellationToken, ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken)
- Source:
 - HybridCache.cs
 
Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.
public System.Threading.Tasks.ValueTask<T> GetOrCreateAsync<T>(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler key, Func<System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<T>> factory, Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions? options = default, System.Collections.Generic.IEnumerable<string>? tags = default, System.Threading.CancellationToken cancellationToken = default);
	member this.GetOrCreateAsync : DefaultInterpolatedStringHandler * Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
	Public Function GetOrCreateAsync(Of T) (ByRef key As DefaultInterpolatedStringHandler, factory As Func(Of CancellationToken, ValueTask(Of T)), Optional options As HybridCacheEntryOptions = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
    Type Parameters
- T
 
The type of the data being considered.
Parameters
The key of the entry to look for or create.
- factory
 - Func<CancellationToken,ValueTask<T>>
 
Provides the underlying data service if the data is not available in the cache.
- options
 - HybridCacheEntryOptions
 
Additional options for this cache entry.
- tags
 - IEnumerable<String>
 
The tags to associate with this cache item.
- cancellationToken
 - CancellationToken
 
The CancellationToken used to propagate notifications that the operation should be canceled.
Returns
The data, either from cache or the underlying data service.
Applies to
GetOrCreateAsync<T>(String, Func<CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken)
- Source:
 - HybridCache.cs
 
- Source:
 - HybridCache.cs
 
Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.
public System.Threading.Tasks.ValueTask<T> GetOrCreateAsync<T>(string key, Func<System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<T>> factory, Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions? options = default, System.Collections.Generic.IEnumerable<string>? tags = default, System.Threading.CancellationToken cancellationToken = default);
	member this.GetOrCreateAsync : string * Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
	Public Function GetOrCreateAsync(Of T) (key As String, factory As Func(Of CancellationToken, ValueTask(Of T)), Optional options As HybridCacheEntryOptions = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
    Type Parameters
- T
 
The type of the data being considered.
Parameters
- key
 - String
 
The key of the entry to look for or create.
- factory
 - Func<CancellationToken,ValueTask<T>>
 
Provides the underlying data service if the data is not available in the cache.
- options
 - HybridCacheEntryOptions
 
Additional options for this cache entry.
- tags
 - IEnumerable<String>
 
The tags to associate with this cache item.
- cancellationToken
 - CancellationToken
 
The CancellationToken used to propagate notifications that the operation should be canceled.
Returns
The data, either from cache or the underlying data service.
Applies to
GetOrCreateAsync<TState,T>(ReadOnlySpan<Char>, TState, Func<TState, CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken)
- Source:
 - HybridCache.cs
 
Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.
public virtual System.Threading.Tasks.ValueTask<T> GetOrCreateAsync<TState,T>(ReadOnlySpan<char> key, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<T>> factory, Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions? options = default, System.Collections.Generic.IEnumerable<string>? tags = default, System.Threading.CancellationToken cancellationToken = default);
	abstract member GetOrCreateAsync : ReadOnlySpan<char> * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
override this.GetOrCreateAsync : ReadOnlySpan<char> * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
	Public Overridable Function GetOrCreateAsync(Of TState, T) (key As ReadOnlySpan(Of Char), state As TState, factory As Func(Of TState, CancellationToken, ValueTask(Of T)), Optional options As HybridCacheEntryOptions = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
    Type Parameters
- TState
 
The type of additional state required by factory.
- T
 
The type of the data being considered.
Parameters
- key
 - ReadOnlySpan<Char>
 
The key of the entry to look for or create.
- state
 - TState
 
The state required for factory.
- factory
 - Func<TState,CancellationToken,ValueTask<T>>
 
Provides the underlying data service if the data is not available in the cache.
- options
 - HybridCacheEntryOptions
 
Additional options for this cache entry.
- tags
 - IEnumerable<String>
 
The tags to associate with this cache item.
- cancellationToken
 - CancellationToken
 
The CancellationToken used to propagate notifications that the operation should be canceled.
Returns
The data, either from cache or the underlying data service.
Remarks
Implementors may use the key span to attempt a local-cache synchronous 'get' without requiring the key as a String.
Applies to
GetOrCreateAsync<TState,T>(DefaultInterpolatedStringHandler, TState, Func<TState,CancellationToken,ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken)
- Source:
 - HybridCache.cs
 
Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.
public System.Threading.Tasks.ValueTask<T> GetOrCreateAsync<TState,T>(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler key, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<T>> factory, Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions? options = default, System.Collections.Generic.IEnumerable<string>? tags = default, System.Threading.CancellationToken cancellationToken = default);
	member this.GetOrCreateAsync : DefaultInterpolatedStringHandler * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
	Public Function GetOrCreateAsync(Of TState, T) (ByRef key As DefaultInterpolatedStringHandler, state As TState, factory As Func(Of TState, CancellationToken, ValueTask(Of T)), Optional options As HybridCacheEntryOptions = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
    Type Parameters
- TState
 
The type of additional state required by factory.
- T
 
The type of the data being considered.
Parameters
The key of the entry to look for or create.
- state
 - TState
 
The state required for factory.
- factory
 - Func<TState,CancellationToken,ValueTask<T>>
 
Provides the underlying data service if the data is not available in the cache.
- options
 - HybridCacheEntryOptions
 
Additional options for this cache entry.
- tags
 - IEnumerable<String>
 
The tags to associate with this cache item.
- cancellationToken
 - CancellationToken
 
The CancellationToken used to propagate notifications that the operation should be canceled.
Returns
The data, either from cache or the underlying data service.
Applies to
GetOrCreateAsync<TState,T>(String, TState, Func<TState,CancellationToken, ValueTask<T>>, HybridCacheEntryOptions, IEnumerable<String>, CancellationToken)
- Source:
 - HybridCache.cs
 
- Source:
 - HybridCache.cs
 
Asynchronously gets the value associated with the key if it exists, or generates a new entry using the provided key and a value from the given factory if the key is not found.
public abstract System.Threading.Tasks.ValueTask<T> GetOrCreateAsync<TState,T>(string key, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<T>> factory, Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions? options = default, System.Collections.Generic.IEnumerable<string>? tags = default, System.Threading.CancellationToken cancellationToken = default);
	abstract member GetOrCreateAsync : string * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'T>> * Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
	Public MustOverride Function GetOrCreateAsync(Of TState, T) (key As String, state As TState, factory As Func(Of TState, CancellationToken, ValueTask(Of T)), Optional options As HybridCacheEntryOptions = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
    Type Parameters
- TState
 
The type of additional state required by factory.
- T
 
The type of the data being considered.
Parameters
- key
 - String
 
The key of the entry to look for or create.
- state
 - TState
 
The state required for factory.
- factory
 - Func<TState,CancellationToken,ValueTask<T>>
 
Provides the underlying data service if the data is not available in the cache.
- options
 - HybridCacheEntryOptions
 
Additional options for this cache entry.
- tags
 - IEnumerable<String>
 
The tags to associate with this cache item.
- cancellationToken
 - CancellationToken
 
The CancellationToken used to propagate notifications that the operation should be canceled.
Returns
The data, either from cache or the underlying data service.