ZiggyCreatures / FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
MIT License
1.65k stars 87 forks source link

[FEATURE] Get List by Type of Key Prefix ? #173

Closed sgf closed 1 year ago

sgf commented 1 year ago

Problem

need get all api.

Solution

  1. maybe can be get list by GetListBy<TType>, FusionCache cached the objs by TType inside?
  2. or when call GetOrSet($"{TType}:{id}",...) the key can be indexed by some thing like Perfix Tree.then we could be search by GetListBy($"{TType}:",....) to get all StartWith $"{TType}:"

Alternatives

no good way

Additional context

nothing

jodydonetti commented 1 year ago

Hi @sgf , and thanks for using FusionCache!

FusionCache is based on the common .NET abstractions IMemoryCache and IDistributedCache, as explained in a similar issue here:

FusionCache has been designed to use the 2 common caching abstractions in .NET: IMemoryCache and IDistributedCache, so that any available impl (mostly for IDistributedCache of course) could've been easily used, without anyone having to explicitly create an implementation of, say, a custom IFusionCacheLayer or something like that. Of course this has advantages - like the one mentioned above - but also disadvantages, like being limited to the features defined in those abstractions.

Because of this, any feature of FusionCache must be either available in those abstractions or implementable on top of them, so the feature you are asking is not doable with the (current, at least) design of FusionCache.

Let me know if this helped.