I want to add some counters to several c# WebApi Controllers using Redis and the StackExchange.Redis client.
I have never used Redis before, however, I have read the docs, setup a server and it appears to be very straightforward to get the results I am looking for.
Having read the StackExchange.Redis docs, I am concerned about the following...
ConnectionMultiplexer does a lot, it is designed to be shared and reused between callers. You should not create a ConnectionMultiplexer per operation.
I have googled and found several examples for simple c# console apps (the technique here is obvious but not relevant to WebApi), I have found examples of using the StackExchange.Redis client on microsoft pages, they too emphasize the importance of sharing the ConnectionMultiplexer, but after hours, I am still no further forwards in understanding how to achieve this in a c# .NET WebApi
Would someone be kind enough to point me in the right direction?
I need to make some simple calls to Redis, namely INCR counter 1, DECR counter 1 and GETSET counter 0 (to reset)
As the counters are not critical, I also want to ensure that if for any reason the connection to the redis server is unavailable to code continues in a timely manner.
Many thanks
Rich