/// <summary> /// Return the result of the <paramref name="query" /> from the cache if possible. Otherwise, /// materialize asynchronously the query and cache the result before being returned. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="query">The query to cache.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="tags"> /// A variable-length parameters list containing tags to expire cached /// entries. /// </param> /// <returns>The result of the query.</returns> public static Task <T> FromCacheAsync <T>(this QueryDeferred <T> query, CancellationToken cancellationToken = default(CancellationToken), params string[] tags) { return(query.FromCacheAsync(QueryCacheManager.DefaultMemoryCacheEntryOptions, cancellationToken, tags)); }
/// <summary> /// Return the result of the <paramref name="query" /> from the cache. If the query is not cached /// yet, the query is materialized and cached before being returned. /// </summary> /// <typeparam name="T">The generic type of the query.</typeparam> /// <param name="query">The query to cache in the QueryCacheManager.</param> /// <param name="options">The cache entry options to use to cache the query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="tags"> /// A variable-length parameters list containing tags to expire cached /// entries. /// </param> /// <returns>The result of the query.</returns> public static Task <T> FromCacheAsync <T>(this QueryDeferred <T> query, MemoryCacheEntryOptions options, params string[] tags) { return(query.FromCacheAsync(options, default(CancellationToken), tags)); }
/// <summary> /// Return the result of the <paramref name="query" /> from the cache. If the query is not cached /// yet, the query is materialized asynchronously and cached before being returned. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="query">The query to cache in the QueryCacheManager.</param> /// <param name="absoluteExpiration">The fixed date and time at which the cache entry will expire.</param> /// <param name="tags"> /// A variable-length parameters list containing tags to expire cached /// entries. /// </param> /// <returns>The result of the query.</returns> public static Task <T> FromCacheAsync <T>(this QueryDeferred <T> query, DateTimeOffset absoluteExpiration, params string[] tags) { return(query.FromCacheAsync(absoluteExpiration, default(CancellationToken), tags)); }
/// <summary> /// Return the result of the <paramref name="query" /> from the cache. If the query is not cached /// yet, the query is materialized asynchronously and cached before being returned. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="query">The query to cache in the QueryCacheManager.</param> /// <param name="tags"> /// A variable-length parameters list containing tags to expire cached /// entries. /// </param> /// <returns>The result of the query.</returns> public static Task <T> FromCacheAsync <T>(this QueryDeferred <T> query, params string[] tags) { return(query.FromCacheAsync(QueryCacheManager.DefaultCacheItemPolicy, default(CancellationToken), tags)); }
/// <summary> /// Return the result of the <paramref name="query" /> from the cache if possible. Otherwise, materialize /// asynchronously the query and cache the result /// before being returned. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="query">The query to cache.</param> /// <param name="tags"> /// A variable-length parameters list containing tags to expire cached /// entries. /// </param> /// <returns>The result of the query.</returns> public static async Task <T> FromCacheAsync <T>(this QueryDeferred <T> query, params string[] tags) { return(await query.FromCacheAsync(QueryCacheManager.DefaultMemoryCacheEntryOptions, tags)); }