Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c1db97a

Browse files
committed
Update README.md
1 parent e485889 commit c1db97a

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

README.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,38 +75,43 @@ Any additional configuration can be specified as QueryString parameters. The ful
7575

7676
## Redis Client Managers
7777

78-
The recommended way to access the RedisClient is to use one of the available Client Managers:
78+
The recommended way to access `RedisClient` instances is to use one of the available Thread-Safe Client Managers below. Client Managers are connection factories which is ideally registered as a Singleton either in your IOC or static classes.
7979

80-
#### `RedisManagerPool`
80+
#### RedisManagerPool
8181

82-
With the enhanced Redis URI Connection Strings we've been able to simplify and streamline the existing `PooledRedisClientManager`
83-
implementation that's been extracted out into a new clients manager called `RedisManagerPool`.
82+
With the enhanced Redis URI Connection Strings we've been able to simplify and streamline the existing `PooledRedisClientManager` implementation and have extracted it out into a new clients manager called `RedisManagerPool`.
8483

85-
In addition to removing all above options on the Client Manager itself, we've also removed readonly connection strings so the configuration
86-
ends up much simpler and more aligned with the common use-case:
84+
In addition to removing all above options on the Client Manager itself, readonly connection strings have also been removed so the configuration ends up much simpler and more aligned with the common use-case:
8785

8886
```csharp
8987
container.Register<IRedisClientsManager>(c =>
9088
new RedisManagerPool(redisConnectionString));
9189
```
9290

93-
#### `PooledRedisClientManager`
91+
**Pooling Behavior**
92+
93+
Any connections required after the maximum Pool size has been reached will be created and disposed outside of the Pool. By not being restricted to a maximum pool size, the pooling behavior in `RedisManagerPool` can maintain a smaller connection pool size at the cost of potentially having a higher opened/closed connection count.
94+
95+
#### PooledRedisClientManager
9496

9597
If you prefer to define options on the Client Manager itself or you want to provide separate Read/Write and ReadOnly
9698
(i.e. Master and Slave) redis-servers, use the `PooledRedisClientManager` instead:
9799

98100
```csharp
99101
container.Register<IRedisClientsManager>(c =>
100102
new PooledRedisClientManager(redisReadWriteHosts, redisReadOnlyHosts) {
101-
ConnectTimeout = 100,
102-
//...
103-
});
103+
ConnectTimeout = 100,
104+
//...
105+
});
104106
```
105107

106-
#### `BasicRedisClientManager`
108+
**Pooling Behavior**
107109

108-
If don't want to use connection pooling (i.e. your accessing a local redis-server instance)
109-
you can use a basic (non-pooled) Clients Manager:
110+
The `PooledRedisClientManager` imposes a maximum connection limit and when its maximum pool size has been reached will instead block on any new connection requests until the next `RedisClient` is released back into the pool. If no client became available within `PoolTimeout`, a Pool `TimeoutException` will be thrown.
111+
112+
#### BasicRedisClientManager
113+
114+
If don't want to use connection pooling (i.e. your accessing a local redis-server instance) you can use a basic (non-pooled) Clients Manager which creates a new `RedisClient` instance each time:
110115

111116
```csharp
112117
container.Register<IRedisClientsManager>(c =>
@@ -119,27 +124,26 @@ Once registered, accessing the RedisClient is the same in all Client Managers, e
119124

120125
```csharp
121126
var clientsManager = container.Resolve<IRedisClientsManager>();
122-
123127
using (IRedisClient redis = clientsManager.GetClient())
124128
{
125-
redis.IncrementValue("counter");
126-
List<string> days = redis.GetAllItemsFromList("days");
129+
redis.IncrementValue("counter");
130+
List<string> days = redis.GetAllItemsFromList("days");
127131

128-
//Access Typed API
129-
var redisTodos = redis.As<Todo>();
132+
//Access Typed API
133+
var redisTodos = redis.As<Todo>();
130134

131135
redisTodos.Store(new Todo {
132136
Id = redisTodos.GetNextSequence(),
133137
Content = "Learn Redis",
134138
});
135139

136-
var todo = redisTodos.GetById(1);
140+
var todo = redisTodos.GetById(1);
137141

138-
//Access Native Client
139-
var redisNative = (IRedisNativeClient)redis;
142+
//Access Native Client
143+
var redisNative = (IRedisNativeClient)redis;
140144

141-
redisNative.Incr("counter");
142-
List<string> days = redisNative.LRange("days", 0, -1);
145+
redisNative.Incr("counter");
146+
List<string> days = redisNative.LRange("days", 0, -1);
143147
}
144148
```
145149

0 commit comments

Comments
 (0)