private T RecuperarDoCache <T, ID>(CacheMemoria <T, ID> cache, ID id, bool forcarAtualizacao) where T : class, new() { return(forcarAtualizacao ? null : cache.RecuperarDoCache(id)); }
/// <summary> /// Recupera um item a partir do cache, se existir. Caso não exista, cria um mecanismo para recuperação do /// dado a partir do banco e depois atualiza o cache. /// </summary> protected Lazy <T> ObterUsandoCache <T, ID>(CacheMemoria <T, ID> cache, ID id, Func <T> recuperarDoBanco, bool forcarAtualizacao = false) where T : class, new() { T itemCache = RecuperarDoCache(cache, id, forcarAtualizacao); if (itemCache != null) { return(new Lazy <T>(() => itemCache)); } return(new Lazy <T>(() => { itemCache = RecuperarDoCache(cache, id, forcarAtualizacao); if (itemCache == null) { try { itemCache = recuperarDoBanco() ?? new T(); } catch { itemCache = new T(); } cache.AtualizarItemNoCache(itemCache, id); } return itemCache; })); }
static ClienteDTO() { cacheDadosCliente = new CacheMemoria <DadosCliente, uint>("dadosCliente"); }
static DadosChapaVidroDTO() { cacheChapasVidro = new CacheMemoria <ChapaVidro, uint>("chapasVidro"); }
static DadosAmbienteDTO() { cacheAmbientes = new CacheMemoria <List <IAmbienteCalculo>, string>("cacheAmbientes"); }
static DadosGrupoSubgrupoDTO() { cacheGrupos = new CacheMemoria <GrupoProd, int>("cacheGrupos"); cacheSubgrupos = new CacheMemoria <SubgrupoProd, int>("cacheSubgrupos"); }
static DadosProdutoDTO() { cacheProdutos = new CacheMemoria <Produto, int>("produtos"); cacheDescontosAcrescimosCliente = new CacheMemoria <DescontoAcrescimoCliente, KeyValuePair <uint, uint?> >("descontosAcrescimosCliente"); }
static BaseCadastroAtualizacaoDto() { CACHE_CONVERSORES = new CacheMemoria <object, string>("cacheConversores", 10); }
static RecalcularOrcamento() { cacheOrcamentos = new CacheMemoria <Data.Model.Orcamento, string>("orcamentos"); }
static DadosBaixaEstoqueDTO() { cacheProdutosBaixaEstoque = new CacheMemoria <List <ProdutoBaixaEstoque>, int>("produtosBaixaEstoque"); }
static GenericBenef() { cacheBeneficiamentos = new CacheMemoria <BenefConfig, uint>("beneficiamentos"); }