public PokemonsCacheService( IMemoryCache memoryCache, ILogger <PokemonsCacheService> logger, IPokemonsService pokemonsService) { _memoryCache = memoryCache; _logger = logger; _pokemonsService = pokemonsService; _typeName = GetType().Name; }
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); }
public async Task <List <DTO.EvolutionChainPokemon> > GetEvolutionChain(int id, [FromServices] IPokemonsService service, [FromServices] IMemoryCache cache) { var evolutionChain = cache.Get <List <DTO.EvolutionChainPokemon> >($"EvolutionChain{id}"); if (evolutionChain != null) { return(evolutionChain); } evolutionChain = await service.GetEvolutionChain(id); cache.Set($"EvolutionChain{id}", evolutionChain); return(evolutionChain); }
public async Task <DTO.PokemonStats> GetMaxStats([FromServices] IPokemonsService service) { return(await service.GetMaxStats()); }
public async Task <List <DTO.PokemonList> > GetAll([FromServices] IPokemonsService service) { return(await service.GetAll()); }