public Task <Genre> GetByIdAsync(int id, CancellationToken ct = default)
 => _cache.GetOrCreateAsync <Genre>(id,
                                    async entry =>
 {
     entry.SetSlidingExpiration(TimeSpan.FromSeconds(604800));
     var genres = await _context.GetGenreAsync(id);
     return(genres.FirstOrDefault());
 });
        public async Task <Genre> GetByIdAsync(int id, CancellationToken ct = default(CancellationToken))
        {
            var cachedGenre = _cache.Get <Genre>(id);

            if (cachedGenre != null)
            {
                return(cachedGenre);
            }

            var dbGenre = _context.GetGenreAsync(id).Result.First();

            var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(604800));

            _cache.Set(dbGenre.GenreId, dbGenre, cacheEntryOptions);

            return(dbGenre);
        }
        public async Task <Genre> GetByIdAsync(int id, CancellationToken ct = default)
        {
            var genres = await _context.GetGenreAsync(id);

            return(genres.FirstOrDefault());
        }