EasyCaching icon indicating copy to clipboard operation
EasyCaching copied to clipboard

GetByPrefix method on IHybridCache

Open umar-ulabs opened this issue 1 year ago • 5 comments

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.

umar-ulabs avatar Jul 22 '22 22:07 umar-ulabs

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

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

catcherwong avatar Aug 07 '22 06:08 catcherwong

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?

umar-ulabs avatar Aug 13 '22 20:08 umar-ulabs

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.

catcherwong avatar Aug 15 '22 00:08 catcherwong

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

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

umar-ulabs avatar Aug 15 '22 01:08 umar-ulabs