dotnetcore / EasyCaching

:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
MIT License
1.95k stars 322 forks source link

GetByPrefix method on IHybridCache #388

Open umar-ulabs opened 2 years ago

umar-ulabs commented 2 years ago

I am in dare need of the GetByPrefix method on IHybridCache, how can I add it back. I learned it was removed from 0.5 version. Please help.

catcherwong commented 2 years ago

@umar-ulabs Thanks for your interest in this project.

Could you show us why you need this method on IHybridCache?

umar-ulabs commented 2 years ago

IEasyCachingProvider has a method "GetByPrefixAsync" but IHybridCachingProvider doesn't. Since I am using IHybridCachingProvider as layered(in memory and redis) caching, I had to change the core feature of my application. I had read somewhere that there was "GetByPrefixAsync" on IHybridCachingProvider interface but was remove in version 0.5 or something. Is there a way to bring it back?

catcherwong commented 2 years ago

After v0.5.0, IHybridCachingProvider was redesigned and we have found that few people have a demand for this method, so we remove it.

BTW, in design, if the local cache hits, the result is directly returned.

If the prefix is used to obtain the data, it should be considered that if the number of local caches is less than the number of distributed caches, incomplete data may be obtained at this time.

umar-ulabs commented 2 years ago

for now I am just getting items one by one, I hope it doesn't cause any problems ` var items = new List();

        foreach (var key in keys)
        {
            var data = await _cacheManager.GetAsync<V>(key);
            if (data != null && data.Value != null)
            {
                items.Add(data.Value);
            }
        }
        return items;`
robert94p commented 5 months ago

I need this method. It is necessary to obtain all data stored with a specific prefix in the key