• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

Method FromCacheAsync

FromCacheAsync<T>(IQueryable<T>, CachingOptions)

Asynchronously Checks if the result set is available in cache or not. If it is available it is fetched from the cache and returned however if it is not available the query is executed on the database and the result set is stored in cache as well as returned. The result set is encapsulated in a task and returned.

Declaration
public static Task<IEnumerable<T>> FromCacheAsync<T>(this IQueryable<T> query, CachingOptions options)
    where T : class
Parameters
Type Name Description
System.Linq.IQueryable<T> query

The query to be executed.

CachingOptions options

The option that will be used to store the result set.

Returns
Type Description
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<T>>

Returns the result set of the query (encapsulated in a task) from cache if available else from the database and stores it in the cache.

Type Parameters
Name Description
T

The generic type of the collection

FromCacheAsync<T>(QueryDeferred<T>, CachingOptions)

Asynchronously Checks if the result is available in cache or not. If it is available it is fetched from the cache and returned however if it is not available the query is executed on the database and the result is stored in cache as well as returned. The result is encapsulated in a task and returned.

Declaration
public static Task<T> FromCacheAsync<T>(this QueryDeferred<T> query, CachingOptions options)
Parameters
Type Name Description
Alachisoft.NCache.EntityFrameworkCore.QueryDeferred<T> query

The query to be executed.

CachingOptions options

The option that will be used to store the result.

Returns
Type Description
System.Threading.Tasks.Task<T>

Returns the result of the query (encapsulated in a task) from cache if available else from the database and stores it in the cache.

Type Parameters
Name Description
T

The generic type of the result

Back to top Copyright © 2017 Alachisoft