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] Complex query and multi Keys/values getOrSet #172

Closed sgf closed 1 year ago

sgf commented 1 year ago

Problem

Hello, I'm not sure, but I've searched almost all caches. No cache has a similar mechanism to support complex queries. Usually it's simple key values. But this brings a problem. It seems that the display of the list makes it inconvenient to use the values in the cache.

Secondly, even Key/Value often does not support obtaining multiple Key/Value at one time at the API level. For requirements like this, you need to extend the GetOrSet method yourself, right?

Solution

var values=GetOrSet(keys,()=>GetFromDB(keys,..));

Alternatives

create a extension method maybe ?

Additional context

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.