Open troylutton opened 7 years ago
Hello @troylutton ,
Thank you ;)
Redis could be supported, but you will have some work to do. As you specified, everything is already here to be supported, only the class inheriting from IMemoryCache is missing.
QueryCacheManager.Cache = new RedisMemoryCache();
public class RedisMemoryCache : IMemoryCache
{
public void Dispose()
{
throw new NotImplementedException();
}
public bool TryGetValue(object key, out object value)
{
throw new NotImplementedException();
}
public ICacheEntry CreateEntry(object key)
{
throw new NotImplementedException();
}
public void Remove(object key)
{
throw new NotImplementedException();
}
}
We are currently trying to catch up with other requests, so from our side, I don't think we will have the time to code it. But if you do, please share the code so other could benefit from it.
Let me know if I answered correctly to your question.
Best Regards,
Jonathan
Sure, it would work if you implemented a Redis cache by implementing IMemoryCache. But that's not what the IMemoryCache interface is meant for. If I understand the docs correctly, IMemoryCache is for "keeping data in memory on the local server". (https://docs.microsoft.com/en-us/aspnet/core/performance/caching/). Wouldn't IDistributedCache be a better fit? As that's what Redis basically is: a distributed cache.
Not saying you should implement it immediately, or even any time soon. But are you at least open to the idea of also supporting IDistributedCache? What's your take on it? :)
My thought on it is simple: You should have the flexibility to use either of theses caches.
They should have options to choose which cache to use by default.
I have added this request to milestone 2.0 (when I will finally complete migrating all PRO library to .NET Core). So yes, I'm very open to any good idea ;)
@nphmuller good point. Perhaps a generic ICacheService interface could even be used to proxy both and keep the implementation detail out. The methods could be the same or similar but it's more generic.
Using an existing extension like StackExchange.Redis from inside the Redis ICacheService would also make the actual implementation much easier and robust.
Sure, it would work if you implemented a Redis cache by implementing IMemoryCache.
I had a quick try at creating a custom IMemoryCache which uses Redis (IDistributedCache) internally. Unfortunately EFCORE uses the Microsoft.Extensions.Caching.Abstractions.MemoryCacheExtensions.Set() extention methods which I could not easily override.
Looking forward to the milestone 2.0 release :)
Hi there
Firstly, awesome library, great work.
Is Redis cache supported or is able to be supported? In azure I believe that the memory cache is per instance and not available across multiple instances. This makes the query cache far less valuable. I see in EFCORE you're using IMemoryCache. Perhaps if the cache service can be configured or set so that the a redis cache service implementing the interface can be used instead of memory cache?