4

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

2
  • 1
    I think the answer you are looking for can be found here Commented Mar 1, 2016 at 14:25
  • 1
    Very helpful. Many Thanks. Commented Mar 2, 2016 at 23:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.