forked from ServiceStack/ServiceStack.Redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRedisResolver.cs
More file actions
53 lines (43 loc) · 1.64 KB
/
IRedisResolver.cs
File metadata and controls
53 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
namespace ServiceStack.Redis
{
/// <summary>
/// Resolver strategy for resolving hosts and creating clients
/// </summary>
public interface IRedisResolver
{
Func<RedisEndpoint, RedisClient> ClientFactory { get; set; }
int ReadWriteHostsCount { get; }
int ReadOnlyHostsCount { get; }
void ResetMasters(IEnumerable<string> hosts);
void ResetSlaves(IEnumerable<string> hosts);
RedisClient CreateMasterClient(int desiredIndex);
RedisClient CreateSlaveClient(int desiredIndex);
}
public interface IRedisResolverExtended : IRedisResolver
{
RedisClient CreateRedisClient(RedisEndpoint config, bool master);
RedisEndpoint GetReadWriteHost(int desiredIndex);
RedisEndpoint GetReadOnlyHost(int desiredIndex);
}
public interface IHasRedisResolver
{
IRedisResolver RedisResolver { get; set; }
}
public static class RedisResolverExtensions
{
public static RedisClient CreateRedisClient(this IRedisResolver resolver, RedisEndpoint config, bool master)
{
return ((IRedisResolverExtended)resolver).CreateRedisClient(config, master);
}
public static RedisEndpoint GetReadWriteHost(this IRedisResolver resolver, int desiredIndex)
{
return ((IRedisResolverExtended)resolver).GetReadWriteHost(desiredIndex);
}
public static RedisEndpoint GetReadOnlyHost(this IRedisResolver resolver, int desiredIndex)
{
return ((IRedisResolverExtended)resolver).GetReadOnlyHost(desiredIndex);
}
}
}