So I'm using "StackExchange.Redis" and I was wondering if I can get multiple values by key pattern or by key list in order to have one trip to the redis cache and get all the data that I need.
I already tried to use "star" in the key when using the "GetObject" method something like this:
User user = RedisContext.Cache.GetObject("User*");
but this returns null.
And I also tried to get all the keys by pattern which did work but I couldn't get the values in one go, like this:
var endpoint = RedisContext.GetConnectionMultiplexer().GetEndPoints().First();
var keys = RedisContext.GetConnectionMultiplexer().GetServer(endpoint.ToString()).Keys(pattern: "User*");
List<string> keyList = new List<string>();
foreach (var _key in keys)
{
keyList.Add(_key);
}
List<User> users = RedisContext.Cache.GetObjectsByTag<dynamic>(keyList.ToArray());
But this gives me an exception. Is there something that I'm missing?