imperugo / StackExchange.Redis.Extensions

MIT License
607 stars 177 forks source link

added HashGetAllAsyncAtOneTimeAsync. This fetches hash values with mu… #571

Closed FatihKosal closed 9 months ago

FatihKosal commented 9 months ago

There is Task<IDictionary<string, T?>> HashGetAsync(string hashKey, string[] keys, CommandFlags flag = CommandFlags.None); But this has a lot of network round trips against Redis.

But this new method Task<IDictionary<string, T?>> HashGetAllAsyncAtOneTimeAsync(string hashKey, string[] keys, CommandFlags flag = CommandFlags.None);

is fetching values at one time.

In load test that I did run on my local machine for 50 keys with 100 virtual concurrent users, HashGetAllAsyncAtOneTimeAsync worked approximately 3.5 times faster than HashGetAsync.

It uses Lua Script.

imperugo commented 9 months ago

Hi @ FatihKosal

Could you add the unit test to your method so I can test and deploy it?

Thanks

FatihKosal commented 9 months ago

Hi @imperugo added HashGetAllAsyncAtOneTimeAsync_ValueExists_Async test method. It is working by setting KeyPrefix = "" in internal CacheClientTestBase(ISerializer serializer). With KeyPrefix = "MyPrefix__",It is not working fyi.

FatihKosal commented 9 months ago

Hi @imperugo someshow this pull request was closed by me mistakenly So I reopened it. You can test the method that I added as I described at above comment

imperugo commented 9 months ago

Hi @FatihKosal thanks again for the PR. I'm going to merge it and changes some things in order to reduce allocation (like lists allocation with resize, ToArray and so on.

Soon in nuget

imperugo commented 9 months ago

Just reverted and reopen the PR again because the tests are not green.

The data returned byt this line

var data = await Database.ScriptEvaluateAsync(luaScript, redisKeys, flags: commandFlags).ConfigureAwait(false);

has always length 0