StackExchange.Redis.Extensions icon indicating copy to clipboard operation
StackExchange.Redis.Extensions copied to clipboard

Multiple Get (Different Types) without a round-trip

Open glikoz opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe. I want to get different objects without a rond-trip cacheClient.Db0.GetAll<User>(new {"user:1","user:2","user:3"}); cacheClient.Db0.GetAll<Classroom>(new {"classroom:1","classroom:2","classroom:3"});

Describe the solution you'd like How can I get all without a round-trip

Describe alternatives you've considered

Additional context If I use Hashset for different types. How can achieve the same requirement without roundtrip?

glikoz avatar Mar 25 '20 21:03 glikoz

Hi @glikoz the current implementation of GetAll doesn't support different type, it means all the object returned from the method must be the same type.

What you need requires a new implementation.

imperugo avatar Mar 26 '20 11:03 imperugo

I don't see a way to return multiple types (unknown) types from the method, only if we return an object which the user should be able to safely cast to back to a Type he passed as part of a MultiGet request of sorts

EugeneKrapivin avatar Apr 22 '20 21:04 EugeneKrapivin

Hi @EugeneKrapivin it depends on what you need with these method. If you call GetAllAsync<T>(string[] keys] it supposes that all returned items must be the type of T, and it does exactly this right now.

If I call something like GetAllAsync where :

  • Key 1 is typeof(T)
  • Key 2 is typeof(K)
  • Key 3 is typeof(W)

and so on. You could handle this. Of course there are several side effects (i.e. multiple serializations). I've to think about that, but it could be possibile

imperugo avatar Apr 22 '20 22:04 imperugo