dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.26k stars 4.73k forks source link

IDistributedCache Support for `Collection` #36095

Closed John0King closed 11 months ago

John0King commented 5 years ago

Both SqlServer and Redis can implement for Collection cache , and even union support. Please consinder for add follow api

interface IDistributeCache
{
  ...
  IEnumerable<byte[]> GetCollection(string key)
  RemoveCollection(string key);
  void LPushCollection(string key, byte[] item, Opitons option)
  void RPushCollection(string key, byte[] item, Opitons option)
  byte[] LPopCollection(string key)
  byte[] RPopCollection(string key)
}
martelskiy commented 5 years ago

Isn't it better to extend abstraction with a generic method? Like:

GetAsync<T>(string key);

John0King commented 5 years ago

@martelskiy the problem of the <T> is how to serialize/deserialize the object , there are many way like 'Json', 'XML' , 'ProtoBuf' ,Binary

MisinformedDNA commented 5 years ago

@martelskiy the problem of the <T> is how to serialize/deserialize the object , there are many way like 'Json', 'XML' , 'ProtoBuf' ,Binary

@John0King That could easily be worked around by adding a base class and common overloads, or enums or extension methods. Everyone is converting objects to strings or byte arrays, so why not standardize?

ghost commented 4 years ago

As part of the migration of components from dotnet/extensions to dotnet/runtime (https://github.com/aspnet/Announcements/issues/411) we will be bulk closing some of the older issues. If you are still interested in having this issue addressed, just comment and the issue will be automatically reactivated (even if you aren't the author). When you do that, I'll page the team to come take a look. If you've moved on or workaround the issue and no longer need this change, just ignore this and the issue will be closed in 7 days.

If you know that the issue affects a package that has moved to a different repo, please consider re-opening the issue in that repo. If you're unsure, that's OK, someone from the team can help!

John0King commented 4 years ago

anything new on this ?

ghost commented 4 years ago

Paging @dotnet/extensions-migration ! This issue has been revived from staleness. Please take a look and route to the appropriate repository.

analogrelay commented 4 years ago

Adding a new API to IDistributedCache would be extremely breaking so I don't think it's likely, but I'll transfer it over for tracking on the backlog in the dotnet/runtime repo.

John0King commented 4 years ago

@anurse

Adding a new API to IDistributedCache would be extremely breaking

theoretically : yes, fact : no

when people upgrade to a new .net core /asp.net core, there are always breaking changes, for example : EF Core update, but when EF update , the EFCore.SqlServer, EFCore.Sqlite , EFCore.InMemory, and third party like 'EFCore.Npgsql' also update. This is not some kind of remove features, for example : MVC to MVC core , signalR to signalR Core (it's bad example, they are 2 frameworks ), there are manage feature and api not exists in the new api, and I believe people actually need this collection support in caching and they goes to native Redis client library for this feature.

and today the interface can have default implementation,
the default implementation can use System.Text.Json to serialize/deserialize to JSON Array and to store to current GetAsync(byte[]) method

adamsitnik commented 11 months ago

Adding a new API to IDistributedCache would be extremely breaking so I don't think it's likely, but I'll transfer it over for tracking on the backlog in the dotnet/runtime repo.

Yes, it would be a breaking change. Since there were not upvotes or any other feedback from other users for over three years I am going to close the issue. I am sorry, but we are not going to implement it in the near future. Thanks!