示例#1
0
        /// <summary>
        /// Get value from Cache Engine
        /// </summary>
        /// <param name="queryFilter">Optional filter to run against data coming from cache</param>
        /// <param name="forceImmediateReload">Setting this to true will tell the cache to reload the data at the point it is retrieved</param>
        /// <returns>An IEnumerable of the DB Type.</returns>
        protected async Task <IEnumerable <T> > GetFromCacheAsync(
            Func <T, bool> queryFilter = null,
            bool forceImmediateReload  = false)
        {
            var cachedData = await CacheContainer.GetAndLoadCacheItemAsync(this.Context,
                                                                           cacheName,
                                                                           reloadMethod,
                                                                           forceImmediateReload,
                                                                           cacheTimeoutInMinutes);

            if (queryFilter == null)
            {
                return(cachedData.Copy());
            }
            return(cachedData.Where(queryFilter).ToList().Copy());
        }