예제 #1
0
        public async Task <DTO.FullPokemon> Get(int id, [FromServices] IPokemonsService service,
                                                [FromServices] IMemoryCache cache)
        {
            var pokemon = cache.Get <DTO.FullPokemon>($"GetPokemon{id}");

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

            pokemon = await service.Get(id);

            cache.Set($"GetPokemon{id}", pokemon);

            return(pokemon);
        }
예제 #2
0
 public async Task <Pokemon> Get(int id)
 => await _memoryCache.GetOrCreateAsync(
     $"{_typeName}-Get-{id}",
     entry => _pokemonsService.Get(id));