/// <summary> /// Retrieves the user's transactions cached /// </summary> /// <param name="genericRepository">Generic repository to use for queries</param> /// <param name="userId">User to get the transactions for</param> /// <returns>List of cached transactions</returns> public static async Task <IList <TransactionEntity> > TransactionsForUserCached(IUnitOfWork unitOfWork, int userId) { var cacheKey = string.Format(CultureInfo.CurrentCulture, _transactionCacheKeyFormat, userId); return(await SinanceCacheHandler.Cache(key : cacheKey, contentAction : async() => { return await unitOfWork.TransactionRepository.FindAll(item => item.UserId == userId); }, slidingExpiration : true, expirationTimeSpan : new TimeSpan(0, 1, 0, 0))); }
/// <summary> /// Clears the cache for this user's transactions /// </summary> /// <param name="userId">User to clear the transaction cache for</param> public static void ClearTransactionsForUserCached(string userId) { var cacheKey = string.Format(CultureInfo.CurrentCulture, _transactionCacheKeyFormat, userId); SinanceCacheHandler.ClearCache(cacheKey); }