Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class Microsoft.​Extensions.​Caching.​Hybrid.​HybridCache
Assembly: Microsoft.Extensions.Caching.Abstractions
Inheritance: object → HybridCache
Provides multi-tier caching services building on <see cref="T:Microsoft.Extensions.Caching.Distributed.IDistributedCache" /> backends.
Methods
public
System.​Threading.​Tasks.​ValueTask<​T>
GetOrCreateAsync​(string key,
TState state,
System.​Func<​TState, System.​Threading.​CancellationToken, System.​Threading.​Tasks.​ValueTask<​T>> factory,
HybridCacheEntryOptions options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
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.
Returns The data, either from cache or the underlying data service.
key
The key of the entry to look for or create.
state
The state required for <paramref name="factory" /> .
factory
Provides the underlying data service if the data is not available in the cache.
options
Additional options for this cache entry.
tags
The tags to associate with this cache item.
cancellationToken
The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.
public
System.​Threading.​Tasks.​ValueTask<​T>
GetOrCreateAsync​(string key,
System.​Func<​System.​Threading.​CancellationToken, System.​Threading.​Tasks.​ValueTask<​T>> factory,
HybridCacheEntryOptions options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
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.
Returns The data, either from cache or the underlying data service.
key
The key of the entry to look for or create.
factory
Provides the underlying data service if the data is not available in the cache.
options
Additional options for this cache entry.
tags
The tags to associate with this cache item.
cancellationToken
The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.
SetAsync​(string key,
T value,
HybridCacheEntryOptions? options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously sets or overwrites the value associated with the key.
key
The key of the entry to create.
value
The value to assign for this cache entry.
options
Additional options for this cache entry.
tags
The tags to associate with this cache entry.
cancellationToken
The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.
RemoveAsync​(string key,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously removes the value associated with the key if it exists.
RemoveAsync​(System.​Collections.​Generic.​IEnumerable<​string> keys,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously removes the value associated with the key if it exists.
Remarks
Implementors should treat <c>null</c> as empty
RemoveByTagAsync​(System.​Collections.​Generic.​IEnumerable<​string> tags,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously removes all values associated with the specified tags.
Remarks
Implementors should treat <c>null</c> as empty
RemoveByTagAsync​(string tag,
System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously removes all values associated with the specified tag.
public
System.​Threading.​Tasks.​ValueTask<​T>
GetOrCreateAsync​(System.​ReadOnlySpan<​char> key,
System.​Func<​System.​Threading.​CancellationToken, System.​Threading.​Tasks.​ValueTask<​T>> factory,
HybridCacheEntryOptions options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
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.
Returns The data, either from cache or the underlying data service.
key
The key of the entry to look for or create.
factory
Provides the underlying data service if the data is not available in the cache.
options
Additional options for this cache entry.
tags
The tags to associate with this cache item.
cancellationToken
The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.
public
System.​Threading.​Tasks.​ValueTask<​T>
GetOrCreateAsync​(System.​ReadOnlySpan<​char> key,
TState state,
System.​Func<​TState, System.​Threading.​CancellationToken, System.​Threading.​Tasks.​ValueTask<​T>> factory,
HybridCacheEntryOptions options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
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.
Returns The data, either from cache or the underlying data service.
key
The key of the entry to look for or create.
state
The state required for <paramref name="factory" /> .
factory
Provides the underlying data service if the data is not available in the cache.
options
Additional options for this cache entry.
tags
The tags to associate with this cache item.
cancellationToken
The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.
Remarks
Implementors may use the key span to attempt a local-cache synchronous 'get' without requiring the key as a <see cref="T:System.String" /> .
public
System.​Threading.​Tasks.​ValueTask<​T>
GetOrCreateAsync​(System.​Runtime.​CompilerServices.​DefaultInterpolatedStringHandler& key,
System.​Func<​System.​Threading.​CancellationToken, System.​Threading.​Tasks.​ValueTask<​T>> factory,
HybridCacheEntryOptions options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
public
System.​Threading.​Tasks.​ValueTask<​T>
GetOrCreateAsync​(System.​Runtime.​CompilerServices.​DefaultInterpolatedStringHandler& key,
TState state,
System.​Func<​TState, System.​Threading.​CancellationToken, System.​Threading.​Tasks.​ValueTask<​T>> factory,
HybridCacheEntryOptions options = null,
System.​Collections.​Generic.​IEnumerable?<​string> tags = null,
System.​Threading.​CancellationToken cancellationToken = null)
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object