Class QueryCacheExtensions
A static class that contains extension methods for caching Entity Framework query result sets.
Inheritance
Assembly: Alachisoft.NCache.EntityFrameworkCore.dll
Syntax
public static class QueryCacheExtensions : object
Methods
FromCache<T>(QueryDeferred<T>, CachingOptions)
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.
Declaration
public static T FromCache<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 set. |
Returns
Type | Description |
---|---|
T | Returns the result set of the query 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 |
FromCache<T>(QueryDeferred<T>, out String, CachingOptions)
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.
Declaration
public static T FromCache<T>(this QueryDeferred<T> query, out string cacheKey, CachingOptions options)
Parameters
Type | Name | Description |
---|---|---|
Alachisoft.NCache.EntityFrameworkCore.QueryDeferred<T> | query | The query to be executed. |
System.String | cacheKey | The key against which the result will be cached is returned as out parameter. |
CachingOptions | options | The option that will be used to store the result. |
Returns
Type | Description |
---|---|
T | Returns the result of the query 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 |
FromCache<T>(IQueryable<T>, CachingOptions)
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.
Declaration
public static IEnumerable<T> FromCache<T>(this IQueryable<T> query, CachingOptions options)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
CachingOptions | options | The option that will be used to store the result set. |
Returns
Type | Description |
---|---|
IEnumerable<T> | Returns the result set of the query 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 |
FromCache<T>(IQueryable<T>, out String, CachingOptions)
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.
Declaration
public static IEnumerable<T> FromCache<T>(this IQueryable<T> query, out string cacheKey, CachingOptions options)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
System.String | cacheKey | The key against which the result set will be cached is returned as out parameter. |
CachingOptions | options | The option that will be used to store the result set. |
Returns
Type | Description |
---|---|
IEnumerable<T> | Returns the result set of the query 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 |
---|---|
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 |
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 |
---|---|---|
IQueryable<T> | query | The query to be executed. |
CachingOptions | options | The option that will be used to store the result set. |
Returns
Type | Description |
---|---|
Task<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 |
FromCacheOnly<T>(QueryDeferred<T>)
Executes the query on the cache and returns the result as generic type.
Declaration
public static T FromCacheOnly<T>(this QueryDeferred<T> query)
Parameters
Type | Name | Description |
---|---|---|
Alachisoft.NCache.EntityFrameworkCore.QueryDeferred<T> | query | The query to be executed. |
Returns
Type | Description |
---|---|
T | Returns the result of the query after executing it in the cache. In case of no result return the default value. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the result. |
FromCacheOnly<T>(IQueryable<T>)
Executes the query on the cache and returns the result as generic IEnumerable.
Declaration
public static IEnumerable<T> FromCacheOnly<T>(this IQueryable<T> query)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
Returns
Type | Description |
---|---|
IEnumerable<T> | Returns the result set of the query after executing it in the cache. In case of no result return the default values. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |
FromCacheOnlyAsync<T>(QueryDeferred<T>)
Executes the query on the cache Asynchronously and returns the result set as generic IEnumerable encapsulated as a task.
Declaration
public static Task<T> FromCacheOnlyAsync<T>(this QueryDeferred<T> query)
Parameters
Type | Name | Description |
---|---|---|
Alachisoft.NCache.EntityFrameworkCore.QueryDeferred<T> | query | The query to be executed. |
Returns
Type | Description |
---|---|
Task<T> | Returns the result of the query (encapsulated in a task) after executing it in the cache. In case of no result return the default value. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the result |
FromCacheOnlyAsync<T>(IQueryable<T>)
Executes the query on the cache Asynchronously and returns the result set as generic IEnumerable encapsulated as a task.
Declaration
public static Task<IEnumerable<T>> FromCacheOnlyAsync<T>(this IQueryable<T> query)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
Returns
Type | Description |
---|---|
Task<IEnumerable<T>> | Returns the result set of the query (encapsulated in a task) after executing it in the cache. In case of no result return the default values. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |
GetDependency(DependencyType, String, String)
Return the result of the query
from the cache. If the query is not cached
yet, the query is materialized asynchronously and cached before being returned.
Declaration
public static CacheDependency GetDependency(DependencyType targetDatabase, string commandText, string connectionString)
Parameters
Type | Name | Description |
---|---|---|
Alachisoft.NCache.EntityFrameworkCore.DependencyType | targetDatabase | |
System.String | commandText | |
System.String | connectionString |
Returns
Type | Description |
---|---|
CacheDependency | The result of the query. |
LoadIntoCache<T>(QueryDeferred<T>, CachingOptions)
Executes the query on the database irrespective of the fact that the result could have been in the cache and could have been served from there and updates the result in the cache.
Declaration
public static T LoadIntoCache<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 |
---|---|
T | Returns the result of the query after executing it on the databse and storing it in the cache. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the result |
LoadIntoCache<T>(QueryDeferred<T>, out String, CachingOptions)
Executes the query on the database irrespective of the fact that the result could have been in the cache and could have been served from there and updates the result set in the cache.
Declaration
public static T LoadIntoCache<T>(this QueryDeferred<T> query, out string cacheKey, CachingOptions options)
Parameters
Type | Name | Description |
---|---|---|
Alachisoft.NCache.EntityFrameworkCore.QueryDeferred<T> | query | The query to be executed. |
System.String | cacheKey | The key against which the result will be cached is returned as out parameter. |
CachingOptions | options | The option that will be used to store the result. |
Returns
Type | Description |
---|---|
T | Returns the result of the query after executing it on the databse and storing it in the cache. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |
LoadIntoCache<T>(IQueryable<T>, CachingOptions)
Executes the query on the database irrespective of the fact that the result set could have been in the cache and could have been served from there and updates the result set in the cache.
Declaration
public static IEnumerable<T> LoadIntoCache<T>(this IQueryable<T> query, CachingOptions options)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
CachingOptions | options | The option that will be used to store the result set. |
Returns
Type | Description |
---|---|
IEnumerable<T> | Returns the result set of the query after executing it on the databse and storing it in the cache. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |
LoadIntoCache<T>(IQueryable<T>, out String, CachingOptions)
Executes the query on the database irrespective of the fact that the result set could have been in the cache and could have been served from there and updates the result set in the cache.
Declaration
public static IEnumerable<T> LoadIntoCache<T>(this IQueryable<T> query, out string cacheKey, CachingOptions options)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
System.String | cacheKey | The key against which the result set will be cached is returned as out parameter. |
CachingOptions | options | The option that will be used to store the result set. |
Returns
Type | Description |
---|---|
IEnumerable<T> | Returns the result set of the query after executing it on the databse and storing it in the cache. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |
LoadIntoCacheAsync<T>(QueryDeferred<T>, CachingOptions)
Executes the query on the database irrespective of the fact that the result could have been in the cache and could have been served from there and updates the result in the cache.
Declaration
public static Task<T> LoadIntoCacheAsync<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 |
---|---|
Task<T> | Returns the result of the query (encapsulated in a task) after executing it on the databse and storing it in the cache. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |
LoadIntoCacheAsync<T>(IQueryable<T>, CachingOptions)
Executes the query on the database irrespective of the fact that the result set could have been in the cache and could have been served from there and updates the result set in the cache.
Declaration
public static Task<IEnumerable<T>> LoadIntoCacheAsync<T>(this IQueryable<T> query, CachingOptions options)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query to be executed. |
CachingOptions | options | The option that will be used to store the result set. |
Returns
Type | Description |
---|---|
Task<IEnumerable<T>> | Returns the result set of the query (encapsulated in a task) after executing it on the databse and storing it in the cache. |
Type Parameters
Name | Description |
---|---|
T | The generic type of the collection |