public GrupoModel GetByIdExterno( int id, [FromServices] GrupoService service, [FromServices] IMemoryCache cache ) { GrupoModel grupoModel; if (!cache.TryGetValue(id, out grupoModel)) { grupoModel = service.GetById(id, ""); if (grupoModel != null) { var opcoesDoCache = new MemoryCacheEntryOptions() { AbsoluteExpiration = DateTime.Now.AddMinutes(CACHEEMMINUTOS) }; cache.Set(id, grupoModel, opcoesDoCache); } } return(grupoModel); }