Redis OM is designed to make using Redis easier for .NET developers, so naturally the first question one might ask is how would you use it to connect to Redis?
The Redis OM library is an abstraction above a lower level (closer to Redis) library—StackExchange.Redis—which it uses to manage connections to Redis. That is however, an implementation detail which should not be a concern to the user.
RedisConnectionProvider class contains the connection logic, and provides for connections to Redis. The RedisConnectionProvider should only be initialized once in your app's lifetime.
RedisConnectionProvider takes a Redis URI and uses that to initialize a connection to Redis.
Consequentially, all that needs to be done to initialize the client is calling the constructor of
RedisConnectionProvider with a Redis uri. Alternatively, you can connect with a ConnectionConfiguration object.
When connecting to Redis Sentinel, you will need to provide the sentinel
Connecting to a Redis Cluster is similar to connecting to a standalone server, it is advisable however to include at least one other alternative endpoint in the URI as a query parameter in case of a failover event.
There are three primary drivers of Redis in this Library, which can all be accessed from the
provider object after it's been initialize.
- The RedisConnection - this provides a command level interface to Redis, a limited set of commands are directly implemented, but any command can be executed via the
ExecuteAsynccommands. To get a handle to the RedisConnection just use
RedisCollection<T>- This is a generic collection used to access Redis. It provides a fluent interface for retrieving data stored in Redis. To create a
RedisAggregationSet<T>- This is another generic collection used to aggregate data in Redis. It provides a fluent interface for performing mapping & reduction operations on Redis. To create a