aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/CnmSynchronizedCache.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/CnmSynchronizedCache.cs')
-rw-r--r--OpenSim/Framework/CnmSynchronizedCache.cs1492
1 files changed, 746 insertions, 746 deletions
diff --git a/OpenSim/Framework/CnmSynchronizedCache.cs b/OpenSim/Framework/CnmSynchronizedCache.cs
index 418a095..bf588ce 100644
--- a/OpenSim/Framework/CnmSynchronizedCache.cs
+++ b/OpenSim/Framework/CnmSynchronizedCache.cs
@@ -1,746 +1,746 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System; 27using System;
28using System.Collections; 28using System.Collections;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31 31
32namespace OpenSim.Framework 32namespace OpenSim.Framework
33{ 33{
34 /// <summary> 34 /// <summary>
35 /// Synchronized Cenome cache wrapper. 35 /// Synchronized Cenome cache wrapper.
36 /// </summary> 36 /// </summary>
37 /// <typeparam name="TKey"> 37 /// <typeparam name="TKey">
38 /// The type of keys in the cache. 38 /// The type of keys in the cache.
39 /// </typeparam> 39 /// </typeparam>
40 /// <typeparam name="TValue"> 40 /// <typeparam name="TValue">
41 /// The type of values in the cache. 41 /// The type of values in the cache.
42 /// </typeparam> 42 /// </typeparam>
43 /// <remarks> 43 /// <remarks>
44 /// <para> 44 /// <para>
45 /// Enumerator will block other threads, until enumerator's <see cref="IDisposable.Dispose"/> method is called. 45 /// Enumerator will block other threads, until enumerator's <see cref="IDisposable.Dispose"/> method is called.
46 /// "foreach" statement is automatically calling it. 46 /// "foreach" statement is automatically calling it.
47 /// </para> 47 /// </para>
48 /// </remarks> 48 /// </remarks>
49 public class CnmSynchronizedCache<TKey, TValue> : ICnmCache<TKey, TValue> 49 public class CnmSynchronizedCache<TKey, TValue> : ICnmCache<TKey, TValue>
50 { 50 {
51 /// <summary> 51 /// <summary>
52 /// The cache object. 52 /// The cache object.
53 /// </summary> 53 /// </summary>
54 private readonly ICnmCache<TKey, TValue> m_cache; 54 private readonly ICnmCache<TKey, TValue> m_cache;
55 55
56 /// <summary> 56 /// <summary>
57 /// Synchronization root. 57 /// Synchronization root.
58 /// </summary> 58 /// </summary>
59 private readonly object m_syncRoot; 59 private readonly object m_syncRoot;
60 60
61 /// <summary> 61 /// <summary>
62 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class. 62 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class.
63 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class. 63 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class.
64 /// </summary> 64 /// </summary>
65 /// <param name="cache"> 65 /// <param name="cache">
66 /// The cache. 66 /// The cache.
67 /// </param> 67 /// </param>
68 private CnmSynchronizedCache( ICnmCache<TKey, TValue> cache ) 68 private CnmSynchronizedCache( ICnmCache<TKey, TValue> cache )
69 { 69 {
70 m_cache = cache; 70 m_cache = cache;
71 m_syncRoot = m_cache.SyncRoot; 71 m_syncRoot = m_cache.SyncRoot;
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// Returns a <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe). 75 /// Returns a <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe).
76 /// </summary> 76 /// </summary>
77 /// <param name="cache"> 77 /// <param name="cache">
78 /// The <see cref="ICnmCache{TKey,TValue}"/> to synchronize. 78 /// The <see cref="ICnmCache{TKey,TValue}"/> to synchronize.
79 /// </param> 79 /// </param>
80 /// <returns> 80 /// <returns>
81 /// A <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe). 81 /// A <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe).
82 /// </returns> 82 /// </returns>
83 /// <exception cref="ArgumentNullException"> 83 /// <exception cref="ArgumentNullException">
84 /// <paramref name="cache"/>is null. 84 /// <paramref name="cache"/>is null.
85 /// </exception> 85 /// </exception>
86 public static ICnmCache<TKey, TValue> Synchronized( ICnmCache<TKey, TValue> cache ) 86 public static ICnmCache<TKey, TValue> Synchronized( ICnmCache<TKey, TValue> cache )
87 { 87 {
88 if( cache == null ) 88 if( cache == null )
89 throw new ArgumentNullException( "cache" ); 89 throw new ArgumentNullException( "cache" );
90 return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>( cache ); 90 return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>( cache );
91 } 91 }
92 92
93 #region Nested type: SynchronizedEnumerator 93 #region Nested type: SynchronizedEnumerator
94 94
95 /// <summary> 95 /// <summary>
96 /// Synchronized enumerator. 96 /// Synchronized enumerator.
97 /// </summary> 97 /// </summary>
98 private class SynchronizedEnumerator : IEnumerator<KeyValuePair<TKey, TValue>> 98 private class SynchronizedEnumerator : IEnumerator<KeyValuePair<TKey, TValue>>
99 { 99 {
100 /// <summary> 100 /// <summary>
101 /// Enumerator that is being synchronized. 101 /// Enumerator that is being synchronized.
102 /// </summary> 102 /// </summary>
103 private readonly IEnumerator<KeyValuePair<TKey, TValue>> m_enumerator; 103 private readonly IEnumerator<KeyValuePair<TKey, TValue>> m_enumerator;
104 104
105 /// <summary> 105 /// <summary>
106 /// Synchronization root. 106 /// Synchronization root.
107 /// </summary> 107 /// </summary>
108 private object m_syncRoot; 108 private object m_syncRoot;
109 109
110 /// <summary> 110 /// <summary>
111 /// Initializes a new instance of the <see cref="SynchronizedEnumerator"/> class. 111 /// Initializes a new instance of the <see cref="SynchronizedEnumerator"/> class.
112 /// </summary> 112 /// </summary>
113 /// <param name="enumerator"> 113 /// <param name="enumerator">
114 /// The enumerator that is being synchronized. 114 /// The enumerator that is being synchronized.
115 /// </param> 115 /// </param>
116 /// <param name="syncRoot"> 116 /// <param name="syncRoot">
117 /// The sync root. 117 /// The sync root.
118 /// </param> 118 /// </param>
119 public SynchronizedEnumerator( IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot ) 119 public SynchronizedEnumerator( IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot )
120 { 120 {
121 m_syncRoot = syncRoot; 121 m_syncRoot = syncRoot;
122 m_enumerator = enumerator; 122 m_enumerator = enumerator;
123 Monitor.Enter( m_syncRoot ); 123 Monitor.Enter( m_syncRoot );
124 } 124 }
125 125
126 /// <summary> 126 /// <summary>
127 /// Finalizes an instance of the <see cref="SynchronizedEnumerator"/> class. 127 /// Finalizes an instance of the <see cref="SynchronizedEnumerator"/> class.
128 /// </summary> 128 /// </summary>
129 ~SynchronizedEnumerator() 129 ~SynchronizedEnumerator()
130 { 130 {
131 Dispose(); 131 Dispose();
132 } 132 }
133 133
134 #region IEnumerator<KeyValuePair<TKey,TValue>> Members 134 #region IEnumerator<KeyValuePair<TKey,TValue>> Members
135 135
136 /// <summary> 136 /// <summary>
137 /// Gets the element in the collection at the current position of the enumerator. 137 /// Gets the element in the collection at the current position of the enumerator.
138 /// </summary> 138 /// </summary>
139 /// <returns> 139 /// <returns>
140 /// The element in the collection at the current position of the enumerator. 140 /// The element in the collection at the current position of the enumerator.
141 /// </returns> 141 /// </returns>
142 /// <exception cref="InvalidOperationException"> 142 /// <exception cref="InvalidOperationException">
143 /// The enumerator has reach end of collection or <see cref="MoveNext"/> is not called. 143 /// The enumerator has reach end of collection or <see cref="MoveNext"/> is not called.
144 /// </exception> 144 /// </exception>
145 public KeyValuePair<TKey, TValue> Current 145 public KeyValuePair<TKey, TValue> Current
146 { 146 {
147 get { return m_enumerator.Current; } 147 get { return m_enumerator.Current; }
148 } 148 }
149 149
150 /// <summary> 150 /// <summary>
151 /// Gets the current element in the collection. 151 /// Gets the current element in the collection.
152 /// </summary> 152 /// </summary>
153 /// <returns> 153 /// <returns>
154 /// The current element in the collection. 154 /// The current element in the collection.
155 /// </returns> 155 /// </returns>
156 /// <exception cref="InvalidOperationException"> 156 /// <exception cref="InvalidOperationException">
157 /// The enumerator is positioned before the first element of the collection or after the last element. 157 /// The enumerator is positioned before the first element of the collection or after the last element.
158 /// </exception><filterpriority>2</filterpriority> 158 /// </exception><filterpriority>2</filterpriority>
159 object IEnumerator.Current 159 object IEnumerator.Current
160 { 160 {
161 get { return Current; } 161 get { return Current; }
162 } 162 }
163 163
164 /// <summary> 164 /// <summary>
165 /// Releases synchronization lock. 165 /// Releases synchronization lock.
166 /// </summary> 166 /// </summary>
167 public void Dispose() 167 public void Dispose()
168 { 168 {
169 if( m_syncRoot != null ) 169 if( m_syncRoot != null )
170 { 170 {
171 Monitor.Exit( m_syncRoot ); 171 Monitor.Exit( m_syncRoot );
172 m_syncRoot = null; 172 m_syncRoot = null;
173 } 173 }
174 174
175 m_enumerator.Dispose(); 175 m_enumerator.Dispose();
176 GC.SuppressFinalize( this ); 176 GC.SuppressFinalize( this );
177 } 177 }
178 178
179 /// <summary> 179 /// <summary>
180 /// Advances the enumerator to the next element of the collection. 180 /// Advances the enumerator to the next element of the collection.
181 /// </summary> 181 /// </summary>
182 /// <returns> 182 /// <returns>
183 /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. 183 /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
184 /// </returns> 184 /// </returns>
185 /// <exception cref="InvalidOperationException"> 185 /// <exception cref="InvalidOperationException">
186 /// The collection was modified after the enumerator was created. 186 /// The collection was modified after the enumerator was created.
187 /// </exception> 187 /// </exception>
188 public bool MoveNext() 188 public bool MoveNext()
189 { 189 {
190 return m_enumerator.MoveNext(); 190 return m_enumerator.MoveNext();
191 } 191 }
192 192
193 /// <summary> 193 /// <summary>
194 /// Sets the enumerator to its initial position, which is before the first element in the collection. 194 /// Sets the enumerator to its initial position, which is before the first element in the collection.
195 /// </summary> 195 /// </summary>
196 /// <exception cref="InvalidOperationException"> 196 /// <exception cref="InvalidOperationException">
197 /// The collection was modified after the enumerator was created. 197 /// The collection was modified after the enumerator was created.
198 /// </exception> 198 /// </exception>
199 public void Reset() 199 public void Reset()
200 { 200 {
201 m_enumerator.Reset(); 201 m_enumerator.Reset();
202 } 202 }
203 203
204 #endregion 204 #endregion
205 } 205 }
206 206
207 #endregion 207 #endregion
208 208
209 #region ICnmCache<TKey,TValue> Members 209 #region ICnmCache<TKey,TValue> Members
210 210
211 /// <summary> 211 /// <summary>
212 /// Gets current count of elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 212 /// Gets current count of elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
213 /// </summary> 213 /// </summary>
214 /// <remarks> 214 /// <remarks>
215 /// <para> 215 /// <para>
216 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 216 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
217 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 217 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
218 /// </para> 218 /// </para>
219 /// </remarks> 219 /// </remarks>
220 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 220 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
221 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/> 221 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/>
222 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 222 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
223 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 223 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
224 public int Count 224 public int Count
225 { 225 {
226 get 226 get
227 { 227 {
228 lock( m_syncRoot ) 228 lock( m_syncRoot )
229 { 229 {
230 return m_cache.Count; 230 return m_cache.Count;
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 /// <summary> 235 /// <summary>
236 /// Gets or sets elements expiration time. 236 /// Gets or sets elements expiration time.
237 /// </summary> 237 /// </summary>
238 /// <value> 238 /// <value>
239 /// Elements expiration time. 239 /// Elements expiration time.
240 /// </value> 240 /// </value>
241 /// <remarks> 241 /// <remarks>
242 /// <para> 242 /// <para>
243 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 243 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
244 /// and it is not accessed through <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> method or element's value is 244 /// and it is not accessed through <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> method or element's value is
245 /// not replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method, then it is automatically removed from the 245 /// not replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method, then it is automatically removed from the
246 /// <see cref="ICnmCache{TKey,TValue}"/>. 246 /// <see cref="ICnmCache{TKey,TValue}"/>.
247 /// </para> 247 /// </para>
248 /// <para> 248 /// <para>
249 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time, 249 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time,
250 /// because total size or count of elements stored to cache is larger than <see cref="ICnmCache{TKey,TValue}.MaxSize"/> or <see cref="ICnmCache{TKey,TValue}.MaxCount"/>. 250 /// because total size or count of elements stored to cache is larger than <see cref="ICnmCache{TKey,TValue}.MaxSize"/> or <see cref="ICnmCache{TKey,TValue}.MaxCount"/>.
251 /// </para> 251 /// </para>
252 /// <para> 252 /// <para>
253 /// It is also possible that element stays in cache longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>. 253 /// It is also possible that element stays in cache longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>.
254 /// </para> 254 /// </para>
255 /// <para> 255 /// <para>
256 /// Calling <see cref="ICnmCache{TKey,TValue}.PurgeExpired"/> try to remove all elements that are expired. 256 /// Calling <see cref="ICnmCache{TKey,TValue}.PurgeExpired"/> try to remove all elements that are expired.
257 /// </para> 257 /// </para>
258 /// <para> 258 /// <para>
259 /// To disable time limit in cache, set <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> to <see cref="DateTime.MaxValue"/>. 259 /// To disable time limit in cache, set <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> to <see cref="DateTime.MaxValue"/>.
260 /// </para> 260 /// </para>
261 /// </remarks> 261 /// </remarks>
262 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 262 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
263 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/> 263 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/>
264 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 264 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
265 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 265 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
266 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/> 266 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/>
267 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 267 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
268 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/> 268 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/>
269 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/> 269 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/>
270 public TimeSpan ExpirationTime 270 public TimeSpan ExpirationTime
271 { 271 {
272 get 272 get
273 { 273 {
274 lock( m_syncRoot ) 274 lock( m_syncRoot )
275 { 275 {
276 return m_cache.ExpirationTime; 276 return m_cache.ExpirationTime;
277 } 277 }
278 } 278 }
279 279
280 set 280 set
281 { 281 {
282 lock( m_syncRoot ) 282 lock( m_syncRoot )
283 { 283 {
284 m_cache.ExpirationTime = value; 284 m_cache.ExpirationTime = value;
285 } 285 }
286 } 286 }
287 } 287 }
288 288
289 /// <summary> 289 /// <summary>
290 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements. 290 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements.
291 /// </summary> 291 /// </summary>
292 /// <value> 292 /// <value>
293 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited; 293 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited;
294 /// otherwise, <see langword="false"/>. 294 /// otherwise, <see langword="false"/>.
295 /// </value> 295 /// </value>
296 /// <remarks> 296 /// <remarks>
297 /// <para> 297 /// <para>
298 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 298 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
299 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 299 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
300 /// </para> 300 /// </para>
301 /// </remarks> 301 /// </remarks>
302 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/> 302 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/>
303 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 303 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
304 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 304 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
305 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 305 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
306 public bool IsCountLimited 306 public bool IsCountLimited
307 { 307 {
308 get 308 get
309 { 309 {
310 lock( m_syncRoot ) 310 lock( m_syncRoot )
311 { 311 {
312 return m_cache.IsCountLimited; 312 return m_cache.IsCountLimited;
313 } 313 }
314 } 314 }
315 } 315 }
316 316
317 /// <summary> 317 /// <summary>
318 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements. 318 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements.
319 /// </summary> 319 /// </summary>
320 /// <value> 320 /// <value>
321 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited; 321 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited;
322 /// otherwise, <see langword="false"/>. 322 /// otherwise, <see langword="false"/>.
323 /// </value> 323 /// </value>
324 /// <remarks> 324 /// <remarks>
325 /// <para> 325 /// <para>
326 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 326 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
327 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 327 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
328 /// </para> 328 /// </para>
329 /// </remarks> 329 /// </remarks>
330 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 330 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
331 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/> 331 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/>
332 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/> 332 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/>
333 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/> 333 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/>
334 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 334 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
335 public bool IsSizeLimited 335 public bool IsSizeLimited
336 { 336 {
337 get 337 get
338 { 338 {
339 lock( m_syncRoot ) 339 lock( m_syncRoot )
340 { 340 {
341 return m_cache.IsSizeLimited; 341 return m_cache.IsSizeLimited;
342 } 342 }
343 } 343 }
344 } 344 }
345 345
346 /// <summary> 346 /// <summary>
347 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe). 347 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe).
348 /// </summary> 348 /// </summary>
349 /// <value> 349 /// <value>
350 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe); 350 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe);
351 /// otherwise, <see langword="false"/>. 351 /// otherwise, <see langword="false"/>.
352 /// </value> 352 /// </value>
353 /// <remarks> 353 /// <remarks>
354 /// <para> 354 /// <para>
355 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use 355 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use
356 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class 356 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class
357 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object. 357 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object.
358 /// </para> 358 /// </para>
359 /// </remarks> 359 /// </remarks>
360 /// <seealso cref="ICnmCache{TKey,TValue}.SyncRoot"/> 360 /// <seealso cref="ICnmCache{TKey,TValue}.SyncRoot"/>
361 /// <seealso cref="CnmSynchronizedCache{TKey,TValue}"/> 361 /// <seealso cref="CnmSynchronizedCache{TKey,TValue}"/>
362 public bool IsSynchronized 362 public bool IsSynchronized
363 { 363 {
364 get { return true; } 364 get { return true; }
365 } 365 }
366 366
367 /// <summary> 367 /// <summary>
368 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time. 368 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time.
369 /// </summary> 369 /// </summary>
370 /// <value> 370 /// <value>
371 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements; 371 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements;
372 /// otherwise, <see langword="false"/>. 372 /// otherwise, <see langword="false"/>.
373 /// </value> 373 /// </value>
374 /// <remarks> 374 /// <remarks>
375 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="ICnmCache{TKey,TValue}.Set"/> 375 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="ICnmCache{TKey,TValue}.Set"/>
376 /// or <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> methods in <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> , then element is automatically removed from 376 /// or <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> methods in <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> , then element is automatically removed from
377 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may 377 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may
378 /// stay longer in cache. 378 /// stay longer in cache.
379 /// </remarks> 379 /// </remarks>
380 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 380 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
381 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 381 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
382 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/> 382 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/>
383 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 383 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
384 public bool IsTimeLimited 384 public bool IsTimeLimited
385 { 385 {
386 get 386 get
387 { 387 {
388 lock( m_syncRoot ) 388 lock( m_syncRoot )
389 { 389 {
390 return m_cache.IsTimeLimited; 390 return m_cache.IsTimeLimited;
391 } 391 }
392 } 392 }
393 } 393 }
394 394
395 /// <summary> 395 /// <summary>
396 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>. 396 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>.
397 /// </summary> 397 /// </summary>
398 /// <value> 398 /// <value>
399 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements; 399 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements;
400 /// otherwise maximal allowed count of elements. 400 /// otherwise maximal allowed count of elements.
401 /// </value> 401 /// </value>
402 /// <remarks> 402 /// <remarks>
403 /// <para> 403 /// <para>
404 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 404 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
405 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 405 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
406 /// </para> 406 /// </para>
407 /// </remarks> 407 /// </remarks>
408 public int MaxCount 408 public int MaxCount
409 { 409 {
410 get 410 get
411 { 411 {
412 lock( m_syncRoot ) 412 lock( m_syncRoot )
413 { 413 {
414 return m_cache.MaxCount; 414 return m_cache.MaxCount;
415 } 415 }
416 } 416 }
417 417
418 set 418 set
419 { 419 {
420 lock( m_syncRoot ) 420 lock( m_syncRoot )
421 { 421 {
422 m_cache.MaxCount = value; 422 m_cache.MaxCount = value;
423 } 423 }
424 } 424 }
425 } 425 }
426 426
427 /// <summary> 427 /// <summary>
428 /// <para>Gets maximal allowed element size.</para> 428 /// <para>Gets maximal allowed element size.</para>
429 /// </summary> 429 /// </summary>
430 /// <value> 430 /// <value>
431 /// Maximal allowed element size. 431 /// Maximal allowed element size.
432 /// </value> 432 /// </value>
433 /// <remarks> 433 /// <remarks>
434 /// <para> 434 /// <para>
435 /// If element's size is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is 435 /// If element's size is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is
436 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>. 436 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>.
437 /// </para> 437 /// </para>
438 /// </remarks> 438 /// </remarks>
439 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/> 439 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/>
440 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 440 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
441 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/> 441 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/>
442 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/> 442 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/>
443 public long MaxElementSize 443 public long MaxElementSize
444 { 444 {
445 get 445 get
446 { 446 {
447 lock( m_syncRoot ) 447 lock( m_syncRoot )
448 { 448 {
449 return m_cache.MaxElementSize; 449 return m_cache.MaxElementSize;
450 } 450 }
451 } 451 }
452 } 452 }
453 453
454 /// <summary> 454 /// <summary>
455 /// Gets or sets maximal allowed total size for elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 455 /// Gets or sets maximal allowed total size for elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
456 /// </summary> 456 /// </summary>
457 /// <value> 457 /// <value>
458 /// Maximal allowed total size for elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 458 /// Maximal allowed total size for elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
459 /// </value> 459 /// </value>
460 /// <remarks> 460 /// <remarks>
461 /// <para> 461 /// <para>
462 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure. 462 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure.
463 /// </para> 463 /// </para>
464 /// <para> 464 /// <para>
465 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 465 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
466 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 466 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
467 /// </para> 467 /// </para>
468 /// </remarks> 468 /// </remarks>
469 /// <exception cref="ArgumentOutOfRangeException">value is less than 0.</exception> 469 /// <exception cref="ArgumentOutOfRangeException">value is less than 0.</exception>
470 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 470 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
471 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 471 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
472 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/> 472 /// <seealso cref="ICnmCache{TKey,TValue}.Size"/>
473 public long MaxSize 473 public long MaxSize
474 { 474 {
475 get 475 get
476 { 476 {
477 lock( m_syncRoot ) 477 lock( m_syncRoot )
478 { 478 {
479 return m_cache.MaxSize; 479 return m_cache.MaxSize;
480 } 480 }
481 } 481 }
482 482
483 set 483 set
484 { 484 {
485 lock( m_syncRoot ) 485 lock( m_syncRoot )
486 { 486 {
487 m_cache.MaxSize = value; 487 m_cache.MaxSize = value;
488 } 488 }
489 } 489 }
490 } 490 }
491 491
492 /// <summary> 492 /// <summary>
493 /// Gets total size of elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 493 /// Gets total size of elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
494 /// </summary> 494 /// </summary>
495 /// <value> 495 /// <value>
496 /// Total size of elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 496 /// Total size of elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
497 /// </value> 497 /// </value>
498 /// <remarks> 498 /// <remarks>
499 /// <para> 499 /// <para>
500 /// Normally bytes, but can be any suitable unit of measure. 500 /// Normally bytes, but can be any suitable unit of measure.
501 /// </para> 501 /// </para>
502 /// <para> 502 /// <para>
503 /// Element's size is given when element is added or replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method. 503 /// Element's size is given when element is added or replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method.
504 /// </para> 504 /// </para>
505 /// <para> 505 /// <para>
506 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 506 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
507 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 507 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
508 /// </para> 508 /// </para>
509 /// </remarks> 509 /// </remarks>
510 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 510 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
511 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 511 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
512 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/> 512 /// <seealso cref="ICnmCache{TKey,TValue}.MaxSize"/>
513 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/> 513 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/>
514 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 514 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
515 public long Size 515 public long Size
516 { 516 {
517 get 517 get
518 { 518 {
519 lock( m_syncRoot ) 519 lock( m_syncRoot )
520 { 520 {
521 return m_cache.Size; 521 return m_cache.Size;
522 } 522 }
523 } 523 }
524 } 524 }
525 525
526 /// <summary> 526 /// <summary>
527 /// Gets an object that can be used to synchronize access to the <see cref="ICnmCache{TKey,TValue}"/>. 527 /// Gets an object that can be used to synchronize access to the <see cref="ICnmCache{TKey,TValue}"/>.
528 /// </summary> 528 /// </summary>
529 /// <value> 529 /// <value>
530 /// An object that can be used to synchronize access to the <see cref="ICnmCache{TKey,TValue}"/>. 530 /// An object that can be used to synchronize access to the <see cref="ICnmCache{TKey,TValue}"/>.
531 /// </value> 531 /// </value>
532 /// <remarks> 532 /// <remarks>
533 /// <para> 533 /// <para>
534 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/> 534 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/>
535 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to 535 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to
536 /// <see cref="ICnmCache{TKey,TValue}"/>. 536 /// <see cref="ICnmCache{TKey,TValue}"/>.
537 /// </para> 537 /// </para>
538 /// </remarks> 538 /// </remarks>
539 /// <seealso cref="ICnmCache{TKey,TValue}.IsSynchronized"/> 539 /// <seealso cref="ICnmCache{TKey,TValue}.IsSynchronized"/>
540 /// <seealso cref="CnmSynchronizedCache{TKey,TValue}"/> 540 /// <seealso cref="CnmSynchronizedCache{TKey,TValue}"/>
541 public object SyncRoot 541 public object SyncRoot
542 { 542 {
543 get { return m_syncRoot; } 543 get { return m_syncRoot; }
544 } 544 }
545 545
546 /// <summary> 546 /// <summary>
547 /// Removes all elements from the <see cref="ICnmCache{TKey,TValue}"/>. 547 /// Removes all elements from the <see cref="ICnmCache{TKey,TValue}"/>.
548 /// </summary> 548 /// </summary>
549 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/> 549 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/>
550 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/> 550 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/>
551 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 551 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
552 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 552 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
553 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 553 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
554 public void Clear() 554 public void Clear()
555 { 555 {
556 lock( m_syncRoot ) 556 lock( m_syncRoot )
557 { 557 {
558 m_cache.Clear(); 558 m_cache.Clear();
559 } 559 }
560 } 560 }
561 561
562 /// <summary> 562 /// <summary>
563 /// Returns an enumerator that iterates through the elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 563 /// Returns an enumerator that iterates through the elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
564 /// </summary> 564 /// </summary>
565 /// <returns> 565 /// <returns>
566 /// A <see cref="IEnumerator{T}"/> that can be used to iterate through the collection. 566 /// A <see cref="IEnumerator{T}"/> that can be used to iterate through the collection.
567 /// </returns> 567 /// </returns>
568 /// <filterpriority>1</filterpriority> 568 /// <filterpriority>1</filterpriority>
569 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 569 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
570 { 570 {
571 lock( m_syncRoot ) 571 lock( m_syncRoot )
572 { 572 {
573 return new SynchronizedEnumerator( m_cache.GetEnumerator(), m_syncRoot ); 573 return new SynchronizedEnumerator( m_cache.GetEnumerator(), m_syncRoot );
574 } 574 }
575 } 575 }
576 576
577 /// <summary> 577 /// <summary>
578 /// Purge expired elements from the <see cref="ICnmCache{TKey,TValue}"/>. 578 /// Purge expired elements from the <see cref="ICnmCache{TKey,TValue}"/>.
579 /// </summary> 579 /// </summary>
580 /// <remarks> 580 /// <remarks>
581 /// <para> 581 /// <para>
582 /// Element becomes expired when last access time to it has been longer time than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>. 582 /// Element becomes expired when last access time to it has been longer time than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>.
583 /// </para> 583 /// </para>
584 /// <para> 584 /// <para>
585 /// Depending on <see cref="ICnmCache{TKey,TValue}"/> implementation, some of expired elements 585 /// Depending on <see cref="ICnmCache{TKey,TValue}"/> implementation, some of expired elements
586 /// may stay longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> in the cache. 586 /// may stay longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> in the cache.
587 /// </para> 587 /// </para>
588 /// </remarks> 588 /// </remarks>
589 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 589 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
590 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 590 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
591 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/> 591 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/>
592 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/> 592 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/>
593 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 593 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
594 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 594 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
595 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 595 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
596 public void PurgeExpired() 596 public void PurgeExpired()
597 { 597 {
598 lock( m_syncRoot ) 598 lock( m_syncRoot )
599 { 599 {
600 m_cache.PurgeExpired(); 600 m_cache.PurgeExpired();
601 } 601 }
602 } 602 }
603 603
604 /// <summary> 604 /// <summary>
605 /// Removes element associated with <paramref name="key"/> from the <see cref="ICnmCache{TKey,TValue}"/>. 605 /// Removes element associated with <paramref name="key"/> from the <see cref="ICnmCache{TKey,TValue}"/>.
606 /// </summary> 606 /// </summary>
607 /// <param name="key"> 607 /// <param name="key">
608 /// The key that is associated with element to remove from the <see cref="ICnmCache{TKey,TValue}"/>. 608 /// The key that is associated with element to remove from the <see cref="ICnmCache{TKey,TValue}"/>.
609 /// </param> 609 /// </param>
610 /// <exception cref="ArgumentNullException"> 610 /// <exception cref="ArgumentNullException">
611 /// <paramref name="key"/>is <see langword="null"/>. 611 /// <paramref name="key"/>is <see langword="null"/>.
612 /// </exception> 612 /// </exception>
613 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/> 613 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/>
614 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 614 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
615 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 615 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
616 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 616 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
617 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 617 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
618 public void Remove( TKey key ) 618 public void Remove( TKey key )
619 { 619 {
620 lock( m_syncRoot ) 620 lock( m_syncRoot )
621 { 621 {
622 m_cache.Remove( key ); 622 m_cache.Remove( key );
623 } 623 }
624 } 624 }
625 625
626 /// <summary> 626 /// <summary>
627 /// Removes elements that are associated with one of <paramref name="keys"/> from the <see cref="ICnmCache{TKey,TValue}"/>. 627 /// Removes elements that are associated with one of <paramref name="keys"/> from the <see cref="ICnmCache{TKey,TValue}"/>.
628 /// </summary> 628 /// </summary>
629 /// <param name="keys"> 629 /// <param name="keys">
630 /// The keys that are associated with elements to remove from the <see cref="ICnmCache{TKey,TValue}"/>. 630 /// The keys that are associated with elements to remove from the <see cref="ICnmCache{TKey,TValue}"/>.
631 /// </param> 631 /// </param>
632 /// <exception cref="ArgumentNullException"> 632 /// <exception cref="ArgumentNullException">
633 /// <paramref name="keys"/>is <see langword="null"/>. 633 /// <paramref name="keys"/>is <see langword="null"/>.
634 /// </exception> 634 /// </exception>
635 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/> 635 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/>
636 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/> 636 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/>
637 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 637 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
638 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 638 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
639 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 639 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
640 public void RemoveRange( IEnumerable<TKey> keys ) 640 public void RemoveRange( IEnumerable<TKey> keys )
641 { 641 {
642 lock( m_syncRoot ) 642 lock( m_syncRoot )
643 { 643 {
644 m_cache.RemoveRange( keys ); 644 m_cache.RemoveRange( keys );
645 } 645 }
646 } 646 }
647 647
648 /// <summary> 648 /// <summary>
649 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to 649 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to
650 /// <see cref="ICnmCache{TKey,TValue}"/>. 650 /// <see cref="ICnmCache{TKey,TValue}"/>.
651 /// </summary> 651 /// </summary>
652 /// <param name="key"> 652 /// <param name="key">
653 /// The object used as the key of the element. Can't be <see langword="null"/> reference. 653 /// The object used as the key of the element. Can't be <see langword="null"/> reference.
654 /// </param> 654 /// </param>
655 /// <param name="value"> 655 /// <param name="value">
656 /// The object used as the value of the element to add or replace. <see langword="null"/> is allowed. 656 /// The object used as the value of the element to add or replace. <see langword="null"/> is allowed.
657 /// </param> 657 /// </param>
658 /// <param name="size"> 658 /// <param name="size">
659 /// The element's size. Normally bytes, but can be any suitable unit of measure. 659 /// The element's size. Normally bytes, but can be any suitable unit of measure.
660 /// </param> 660 /// </param>
661 /// <returns> 661 /// <returns>
662 /// <see langword="true"/>if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>; 662 /// <see langword="true"/>if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>;
663 /// otherwise <see langword="false"/>. 663 /// otherwise <see langword="false"/>.
664 /// </returns> 664 /// </returns>
665 /// <exception cref="ArgumentNullException"> 665 /// <exception cref="ArgumentNullException">
666 /// <paramref name="key"/>is <see langword="null"/>. 666 /// <paramref name="key"/>is <see langword="null"/>.
667 /// </exception> 667 /// </exception>
668 /// <exception cref="ArgumentOutOfRangeException"> 668 /// <exception cref="ArgumentOutOfRangeException">
669 /// The element's <paramref name="size"/> is less than 0. 669 /// The element's <paramref name="size"/> is less than 0.
670 /// </exception> 670 /// </exception>
671 /// <remarks> 671 /// <remarks>
672 /// <para> 672 /// <para>
673 /// If element's <paramref name="size"/> is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is 673 /// If element's <paramref name="size"/> is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is
674 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is 674 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is
675 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>. 675 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>.
676 /// </para> 676 /// </para>
677 /// <para> 677 /// <para>
678 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 678 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
679 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 679 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
680 /// </para> 680 /// </para>
681 /// <para> 681 /// <para>
682 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 682 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
683 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 683 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
684 /// </para> 684 /// </para>
685 /// </remarks> 685 /// </remarks>
686 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 686 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
687 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/> 687 /// <seealso cref="ICnmCache{TKey,TValue}.IsCountLimited"/>
688 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/> 688 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/>
689 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 689 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
690 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 690 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
691 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 691 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
692 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 692 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
693 public bool Set( TKey key, TValue value, long size ) 693 public bool Set( TKey key, TValue value, long size )
694 { 694 {
695 lock( m_syncRoot ) 695 lock( m_syncRoot )
696 { 696 {
697 return m_cache.Set( key, value, size ); 697 return m_cache.Set( key, value, size );
698 } 698 }
699 } 699 }
700 700
701 /// <summary> 701 /// <summary>
702 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>. 702 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>.
703 /// </summary> 703 /// </summary>
704 /// <returns> 704 /// <returns>
705 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with 705 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with
706 /// the specified key; otherwise, <see langword="false"/>. 706 /// the specified key; otherwise, <see langword="false"/>.
707 /// </returns> 707 /// </returns>
708 /// <param name="key"> 708 /// <param name="key">
709 /// The key whose <paramref name="value"/> to get. 709 /// The key whose <paramref name="value"/> to get.
710 /// </param> 710 /// </param>
711 /// <param name="value"> 711 /// <param name="value">
712 /// When this method returns, the value associated with the specified <paramref name="key"/>, 712 /// When this method returns, the value associated with the specified <paramref name="key"/>,
713 /// if the <paramref name="key"/> is found; otherwise, the 713 /// if the <paramref name="key"/> is found; otherwise, the
714 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized. 714 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized.
715 /// </param> 715 /// </param>
716 /// <exception cref="ArgumentNullException"> 716 /// <exception cref="ArgumentNullException">
717 /// <paramref name="key"/>is <see langword="null"/>. 717 /// <paramref name="key"/>is <see langword="null"/>.
718 /// </exception> 718 /// </exception>
719 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/> 719 /// <seealso cref="ICnmCache{TKey,TValue}.Set"/>
720 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/> 720 /// <seealso cref="ICnmCache{TKey,TValue}.Remove"/>
721 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 721 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
722 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 722 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
723 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 723 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
724 public bool TryGetValue( TKey key, out TValue value ) 724 public bool TryGetValue( TKey key, out TValue value )
725 { 725 {
726 lock( m_syncRoot ) 726 lock( m_syncRoot )
727 { 727 {
728 return m_cache.TryGetValue( key, out value ); 728 return m_cache.TryGetValue( key, out value );
729 } 729 }
730 } 730 }
731 731
732 /// <summary> 732 /// <summary>
733 /// Returns an enumerator that iterates through the elements stored to <see cref="ICnmCache{TKey,TValue}"/>. 733 /// Returns an enumerator that iterates through the elements stored to <see cref="ICnmCache{TKey,TValue}"/>.
734 /// </summary> 734 /// </summary>
735 /// <returns> 735 /// <returns>
736 /// A <see cref="IEnumerator"/> that can be used to iterate through the collection. 736 /// A <see cref="IEnumerator"/> that can be used to iterate through the collection.
737 /// </returns> 737 /// </returns>
738 /// <filterpriority>1</filterpriority> 738 /// <filterpriority>1</filterpriority>
739 IEnumerator IEnumerable.GetEnumerator() 739 IEnumerator IEnumerable.GetEnumerator()
740 { 740 {
741 return GetEnumerator(); 741 return GetEnumerator();
742 } 742 }
743 743
744 #endregion 744 #endregion
745 } 745 }
746} 746}