Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

354
Visualizações
Get all Cached Objects which are cached using MemoryCache class c#

I want to retrieve all the cache objects that are added using MemoryCache.

I tried the below but it is not retrieving them

System.Web.HttpContext.Current.Cache.GetEnumerator();
System.Web.HttpRuntime.Cache.GetEnumerator();

Note: Retreive all means not just what i know and created, i mean every cache object that gets created in the application.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

This is what i found (it may help some one)

foreach (var item in MemoryCache.Default)
{
   //add the item.keys to list
}
return list;
over 4 years ago · Santiago Trujillo Relatório

0

Here is a better way to enumerate and get the result:

public virtual List<T> GetCache<T>()
{
    List<T> list = new List<T>();
    IDictionaryEnumerator cacheEnumerator = (IDictionaryEnumerator)((IEnumerable)Cache).GetEnumerator();

    while (cacheEnumerator.MoveNext())
        list.Add((T) cacheEnumerator.Value);

    return list;
}
over 4 years ago · Santiago Trujillo Relatório

0

This should also work: MemoryCache.Default.ToList();

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda