-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulk remove on IDistributedCache #36568
Comments
I posted an |
@RehanSaeed It looks like you're missing IDistributedCacheExtended definition in your post. |
We've reached feature complete for .NET 6. Moving to 7. |
Here my proposal: namespace Microsoft.Extensions.Caching.Distributed
{
public interface IDistributedCache
{
void Clear();
// Maybe, a ValueTask would not be a bad idea, but other Async APIs use a normal Task in this class.
Task ClearAsync(CancellationToken cancellationToken = default);
}
public partial class MemoryDistributedCache : IDistributedCache {
public void Clear();
public Task ClearAsync(CancellationToken cancellationToken = default);
}
}
namespace Microsoft.Extensions.Caching.Redis
{
public partial class RedisCache : IDisposable, IDistributedCache {
public void Clear();
public Task ClearAsync(CancellationToken cancellationToken = default);
}
}
namespace Microsoft.Extensions.Caching.StackExchangeRedis
{
public partial class RedisCache : IDisposable, IDistributedCache {
public void Clear();
public Task ClearAsync(CancellationToken cancellationToken = default);
}
}
namespace Microsoft.Extensions.Caching.SqlServer
{
public partial class SqlServerCache : IDistributedCache {
public void Clear();
public Task ClearAsync(CancellationToken cancellationToken = default);
}
} |
Originally posted by @bartonjs in #45593 (comment) It would probably make sense to update only the implementations and not change the interface due to the breaking change. |
We have started using Default Interface Members (DIMs) in Microsoft.Extensions. This may be a candidate to add in .NET 6.0+ APIs just like we did for #66479.
I don't believe the original intention of this issue is to remove all the entries from the cache, but remove a set of them specified by a collection of keys. |
Would it be useful if the IDistibutedCache interface can allow bulk remove?
Unlike the memory cache, removing multiple entries from distributed caches can be an expensive task. Providing an overload of the Remove function that accept an array of keys - e.g. Task Remove(string [] keys) - would allow more efficient implementations of distributed caches.
The text was updated successfully, but these errors were encountered: