dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.08k stars 4.7k forks source link

[API Proposal]: Extend IDistributedCache to also provide keys/provider info #98252

Open thompson-tomo opened 8 months ago

thompson-tomo commented 8 months ago

Background and motivation

I would like a way in which to fetch all the keys in the cache so that i can provide an actuator just like the way in which spring boot does it (https://docs.spring.io/spring-boot/docs/current/actuator-api/htmlsingle/#caches).

API Proposal

Interface extension

namespace System.Collections.Generic;

IEnumerable<CacheItem> GetCacheItems => new IEnumerable<CacheItem>();

Use class as proposed in #98251

API Usage


foreach (var item in _memoryCache.GetCacheItems.ToList())
{
    //build object as per actuator needs which includes 
}

Alternative Designs

Risks

Should be low risk as not a breaking change by providing default implementation.

ghost commented 8 months ago

Tagging subscribers to this area: @dotnet/area-extensions-caching See info in area-owners.md if you want to be subscribed.

Issue Details
### Background and motivation I would like a way in which to fetch all the keys in the cache so that i can provide an actuator just like the way in which spring boot does it (https://docs.spring.io/spring-boot/docs/current/actuator-api/htmlsingle/#caches). ### API Proposal Interface extension ```csharp namespace System.Collections.Generic; IEnumerable GetCacheItems => new IEnumerable(); ``` Use class as proposed in #98251 ### API Usage ```csharp foreach (var item in _memoryCache.GetCacheItems.ToList()) { //build object as per actuator needs which includes } ``` ### Alternative Designs _No response_ ### Risks Should be low risk as not a breaking change by providing default implementation.
Author: thompson-tomo
Assignees: -
Labels: `api-suggestion`, `untriaged`, `area-Extensions-Caching`
Milestone: -
jozkee commented 3 months ago

Related to https://github.com/dotnet/runtime/issues/98251.