How to retrieve a list of Memory Cache keys in asp.net core?

Carlos

To be succinct. Is possible list all register keys from Memory Cache in the .Net Core Web Application?

I didn't find anything in IMemoryCache interface.

Shyju

Currently there is no such method in the IMemoryCache interface to return all the cache keys. As per this github issue comments, i do not think that would be added in the future.

Quoting Eilons comment

I think it's doubtful this would be available because part of the idea with caching is that mere moments after you ask it a question, the answer could have changed. That is, suppose you have the answer to which keys are there - a moment later the cache is purged and the list of keys you have is invalid.

If you need the keys, you should maintain the list of keys in your app while you set items to the cache and use that as needed.

Here is another useful github issue

Will there be GetEnumerator() for MemoryCache ?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ASP.NET Core Custom Authorization & Memory Cache

Can't access memory cache - ASP.NET Core

Asp.Net Core: Use memory cache outside controller

How to cache resources in Asp.net core?

how to use MemoryCache Class to cache and get a list in asp.net core

Access list of active in-memory sessions in asp.net core

How to retrieve the controller type in ASP.NET Core?

How to retrieve RouteValues in ActionSelector in ASP.NET Core

How to retrieve ClaimsPrincipal from JWT in asp.net core

How to retrieve JSON data in controller in ASP.net Core?

ASP .NET Core: How to cache data which depend on user input?

How to cache css,js or images files to asp.net core

how can cache "NotFound" page in asp .net core

How to retrieve data from cache memory?

How to gain access to Asp.Net Core encryption keys?

PostSharp Caching MethodInterceptionAspect using ASP.NET Core in-memory cache

Memory cache seems to differ between endpoints in Asp.Net Core Web Api

Can I use In-Memory Engine for SQL Server Distributed Cache in ASP.NET Core?

Add Cache to ASP.NET Core response

Redis Cache in ASP.NET Core

Asp.Net Core Cache Tag Helper

ASP.Net Core PWA Cache Query

How to save and retrieve images from database using Entity Framework Core in ASP.NET Core web application?

Is there a way to check and clean Certificate Revocation List cache for ASP.NET Core application that is dockerized and run under the Linux?

Asp.Net core 6 session keys

Limitation of memory usage in Asp.net Core

ASP.NET core high memory consume

session in asp.net core in memory

How to display a list of users with Roles - ASP.NET (Core)