Closed ghetze closed 5 years ago
You can declare the policy just once, outside the loop and re-use it within the loop (this will save a large number of allocations and garbage collections):
// outside loop
var policy = Policy
.Handle<RedisConnectionException>()
.WaitAndRetryAsync(/* etc */);
// inside loop
var rslt = policy.ExecuteAsync(...)
You can remove the .ConfigureAwait(false)
. Since you are never await
-ing that task, it adds no value.
You can consider batching with Redis as an alternative to pipelining. You would have to benchmark whether it made any difference for your use case.
Googling reveals a number of existing discussions around your use case:
(and there are without doubt more).
EDIT: link to related question on StackExchange.Redis
Thank you for the response.
Summary: What are you wanting to achieve? StringSetAsync (......) method.
Is my code ok ? or there is a fastest way to accomplish the highest sending speed.
Hi. I'm currently making some tests to see the performance when sending lots of records no a redis db. The idea is to send 30 000 000 records to redis as fast as possible and then to wait for all the results to see how many of them crashed or not. I'm using polly because we need also a retry mechanism. For the sending i use stackexchange.redis Task
What code or approach do you have so far?
( EDITED by @reisenberger for code layout only )