コード例 #1
0
        public override async Task <ShowResultModel> GetResultWithBenchmark(long id)
        {
            string key = $"result+bmk_{id}";
            Func <Task <ShowResultModel> > dbLookup = async() => await base.GetResultWithBenchmark(id).ConfigureAwait(false);

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache).ConfigureAwait(false));
        }
コード例 #2
0
        public override async Task <BenchmarkResultDto> FindById(long id)
        {
            string key = $"result_{id}";
            Func <Task <BenchmarkResultDto> > dbLookup = async() => await base.FindById(id).ConfigureAwait(false);

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache).ConfigureAwait(false));
        }
コード例 #3
0
        public override async Task <IEnumerable <BenchmarkDto> > ListByUser(string userId, int page, int numOfItems)
        {
            string key = $"my_{userId}_{numOfItems}_{page}";
            Func <Task <IEnumerable <BenchmarkDto> > > dbLookup = async() => await base.ListByUser(userId, page, numOfItems).ConfigureAwait(false);

            var expirationOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromSeconds(20));

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache, expirationOptions).ConfigureAwait(false));
        }
コード例 #4
0
        public override async Task <EntityListWithCount <BenchmarkDto> > ListAll(int maxEntities)
        {
            string key = $"latest_withcount_{maxEntities}";
            Func <Task <EntityListWithCount <BenchmarkDto> > > dbLookup = async() => await base.ListAll(maxEntities).ConfigureAwait(false);

            var expirationOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(1));

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache, expirationOptions).ConfigureAwait(false));
        }
コード例 #5
0
        public async Task <BenchmarkDto> FindByIdAndVersion(int id, int version)
        {
            string key = $"{CacheKeyPrefix}_{id}_{version}";
            Func <Task <BenchmarkDto> > dbLookup = async() => await base.FindById(id).ConfigureAwait(false);

            var expirationOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(1));

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache, expirationOptions).ConfigureAwait(false));
        }
コード例 #6
0
        public override async Task <IEnumerable <BenchmarkDto> > ListAll(int numOfItems, int page)
        {
            string key = $"latest_benchmarks_{numOfItems}_{page}";
            Func <Task <IEnumerable <BenchmarkDto> > > dbLookup = async() => await base.ListAll(numOfItems, page).ConfigureAwait(false);

            var expirationOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(1));

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache, expirationOptions).ConfigureAwait(false));
        }
コード例 #7
0
        public override async Task <EntityListWithCount <BenchmarkResultDto> > ListAll(int maxEntities, int benchmarkId)
        {
            string key = $"result+withcnt_{benchmarkId}_{maxEntities}";
            Func <Task <EntityListWithCount <BenchmarkResultDto> > > dbLookup = async() => await base.ListAll(maxEntities, benchmarkId).ConfigureAwait(false);

            var expirationOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromSeconds(30));

            return(await CacheAsideRequestHelper.CacheAsideRequest(dbLookup, key, this.m_memoryCache, expirationOptions).ConfigureAwait(false));
        }