Reputation: 245
I'm using the stack exchange redis library on IIS. This is a very general question which I haven't found an answer to.
If I am recording analytics where I don't care about the response to the redis call, can I do an async say string increment and not await it ever and trust that it will finish and not be cancelled if my request completes\terminates etc?
The goal being to reduce the amount of time the client is waiting for the response to be rendered.
Upvotes: 0
Views: 100
Reputation: 1064204
In the SE-Redis library, there is a feature specifically for this: "fire and forget". Almost every operation accepts an optional CommandFlags
parameter: specify CommandFlags.FireAndForget
(using "or" (|
) to combine if you're already passing another flag) - your command will be sent but the local method will return immediately. You shouldn't really look at it, but the method will immediately return the default value for whatever the declared type is. Finally, it may be easier to use the non-async API, just so the compiler doesn't prompt you to await
it unnecessarily (although again: it won't actually be truly async in this case).
Upvotes: 2