|
6 | 6 |
|
7 | 7 | namespace Enyim.Caching.Configuration
|
8 | 8 | {
|
9 |
| - public class SocketPoolConfiguration : ISocketPoolConfiguration |
10 |
| - { |
11 |
| - private int minPoolSize = 10; |
12 |
| - private int maxPoolSize = 20; |
13 |
| - private TimeSpan connectionTimeout = new TimeSpan(0, 0, 10); |
14 |
| - private TimeSpan receiveTimeout = new TimeSpan(0, 0, 10); |
15 |
| - private TimeSpan deadTimeout = new TimeSpan(0, 0, 10); |
16 |
| - private TimeSpan queueTimeout = new TimeSpan(0, 0, 0, 0, 100); |
17 |
| - private INodeFailurePolicyFactory policyFactory = new FailImmediatelyPolicyFactory(); |
18 |
| - |
19 |
| - int ISocketPoolConfiguration.MinPoolSize |
20 |
| - { |
21 |
| - get { return this.minPoolSize; } |
22 |
| - set { this.minPoolSize = value; } |
23 |
| - } |
24 |
| - |
25 |
| - /// <summary> |
26 |
| - /// Gets or sets a value indicating the maximum amount of sockets per server in the socket pool. |
27 |
| - /// </summary> |
28 |
| - /// <returns>The maximum amount of sockets per server in the socket pool. The default is 20.</returns> |
29 |
| - /// <remarks>It should be 0.75 * (number of threads) for optimal performance.</remarks> |
30 |
| - int ISocketPoolConfiguration.MaxPoolSize |
31 |
| - { |
32 |
| - get { return this.maxPoolSize; } |
33 |
| - set { this.maxPoolSize = value; } |
34 |
| - } |
35 |
| - |
36 |
| - TimeSpan ISocketPoolConfiguration.ConnectionTimeout |
37 |
| - { |
38 |
| - get { return this.connectionTimeout; } |
39 |
| - set |
40 |
| - { |
41 |
| - if (value < TimeSpan.Zero) |
42 |
| - throw new ArgumentOutOfRangeException("value", "value must be positive"); |
43 |
| - |
44 |
| - this.connectionTimeout = value; |
45 |
| - } |
46 |
| - } |
47 |
| - |
48 |
| - TimeSpan ISocketPoolConfiguration.ReceiveTimeout |
49 |
| - { |
50 |
| - get { return this.receiveTimeout; } |
51 |
| - set |
52 |
| - { |
53 |
| - if (value < TimeSpan.Zero) |
54 |
| - throw new ArgumentOutOfRangeException("value", "value must be positive"); |
55 |
| - |
56 |
| - this.receiveTimeout = value; |
57 |
| - } |
58 |
| - } |
59 |
| - |
60 |
| - TimeSpan ISocketPoolConfiguration.QueueTimeout |
61 |
| - { |
62 |
| - get { return this.queueTimeout; } |
63 |
| - set |
64 |
| - { |
65 |
| - if (value < TimeSpan.Zero) |
66 |
| - throw new ArgumentOutOfRangeException("value", "value must be positive"); |
67 |
| - |
68 |
| - this.queueTimeout = value; |
69 |
| - } |
70 |
| - } |
71 |
| - |
72 |
| - TimeSpan ISocketPoolConfiguration.DeadTimeout |
73 |
| - { |
74 |
| - get { return this.deadTimeout; } |
75 |
| - set |
76 |
| - { |
77 |
| - if (value < TimeSpan.Zero) |
78 |
| - throw new ArgumentOutOfRangeException("value", "value must be positive"); |
79 |
| - |
80 |
| - this.deadTimeout = value; |
81 |
| - } |
82 |
| - } |
83 |
| - |
84 |
| - INodeFailurePolicyFactory ISocketPoolConfiguration.FailurePolicyFactory |
85 |
| - { |
86 |
| - get { return this.policyFactory; } |
87 |
| - set |
88 |
| - { |
89 |
| - if (value == null) |
90 |
| - throw new ArgumentNullException("value"); |
91 |
| - |
92 |
| - this.policyFactory = value; |
93 |
| - } |
94 |
| - } |
95 |
| - } |
| 9 | + public class SocketPoolConfiguration : ISocketPoolConfiguration |
| 10 | + { |
| 11 | + private int minPoolSize = 10; |
| 12 | + private int maxPoolSize = 20; |
| 13 | + private TimeSpan connectionTimeout = new TimeSpan(0, 0, 10); |
| 14 | + private TimeSpan receiveTimeout = new TimeSpan(0, 0, 10); |
| 15 | + private TimeSpan deadTimeout = new TimeSpan(0, 0, 10); |
| 16 | + private TimeSpan queueTimeout = new TimeSpan(0, 0, 0, 0, 100); |
| 17 | + private TimeSpan _initPoolTimeout = new TimeSpan(0, 1, 0); |
| 18 | + private INodeFailurePolicyFactory policyFactory = new FailImmediatelyPolicyFactory(); |
| 19 | + |
| 20 | + int ISocketPoolConfiguration.MinPoolSize |
| 21 | + { |
| 22 | + get { return this.minPoolSize; } |
| 23 | + set { this.minPoolSize = value; } |
| 24 | + } |
| 25 | + |
| 26 | + /// <summary> |
| 27 | + /// Gets or sets a value indicating the maximum amount of sockets per server in the socket pool. |
| 28 | + /// </summary> |
| 29 | + /// <returns>The maximum amount of sockets per server in the socket pool. The default is 20.</returns> |
| 30 | + /// <remarks>It should be 0.75 * (number of threads) for optimal performance.</remarks> |
| 31 | + int ISocketPoolConfiguration.MaxPoolSize |
| 32 | + { |
| 33 | + get { return this.maxPoolSize; } |
| 34 | + set { this.maxPoolSize = value; } |
| 35 | + } |
| 36 | + |
| 37 | + TimeSpan ISocketPoolConfiguration.ConnectionTimeout |
| 38 | + { |
| 39 | + get { return this.connectionTimeout; } |
| 40 | + set |
| 41 | + { |
| 42 | + if (value < TimeSpan.Zero) |
| 43 | + throw new ArgumentOutOfRangeException("value", "value must be positive"); |
| 44 | + |
| 45 | + this.connectionTimeout = value; |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + TimeSpan ISocketPoolConfiguration.ReceiveTimeout |
| 50 | + { |
| 51 | + get { return this.receiveTimeout; } |
| 52 | + set |
| 53 | + { |
| 54 | + if (value < TimeSpan.Zero) |
| 55 | + throw new ArgumentOutOfRangeException("value", "value must be positive"); |
| 56 | + |
| 57 | + this.receiveTimeout = value; |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + TimeSpan ISocketPoolConfiguration.QueueTimeout |
| 62 | + { |
| 63 | + get { return this.queueTimeout; } |
| 64 | + set |
| 65 | + { |
| 66 | + if (value < TimeSpan.Zero) |
| 67 | + throw new ArgumentOutOfRangeException("value", "value must be positive"); |
| 68 | + |
| 69 | + this.queueTimeout = value; |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + TimeSpan ISocketPoolConfiguration.InitPoolTimeout |
| 74 | + { |
| 75 | + get { return _initPoolTimeout; } |
| 76 | + set |
| 77 | + { |
| 78 | + if (value < TimeSpan.Zero) |
| 79 | + throw new ArgumentOutOfRangeException("value", "value must be positive"); |
| 80 | + |
| 81 | + _initPoolTimeout = value; |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + TimeSpan ISocketPoolConfiguration.DeadTimeout |
| 86 | + { |
| 87 | + get { return this.deadTimeout; } |
| 88 | + set |
| 89 | + { |
| 90 | + if (value < TimeSpan.Zero) |
| 91 | + throw new ArgumentOutOfRangeException("value", "value must be positive"); |
| 92 | + |
| 93 | + this.deadTimeout = value; |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + INodeFailurePolicyFactory ISocketPoolConfiguration.FailurePolicyFactory |
| 98 | + { |
| 99 | + get { return this.policyFactory; } |
| 100 | + set |
| 101 | + { |
| 102 | + if (value == null) |
| 103 | + throw new ArgumentNullException("value"); |
| 104 | + |
| 105 | + this.policyFactory = value; |
| 106 | + } |
| 107 | + } |
| 108 | + } |
96 | 109 | }
|
97 | 110 |
|
98 | 111 | #region [ License information ]
|
|
0 commit comments