Clover.NET coverage report - Coverage

Coverage timestamp: Friday, May 20, 2005 9:17:00 PM

File Stats: LOC: 123   Methods: 5
NCLOC: 71 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Configuration\Cache\Lru\LruCacheController.cs 0.0 % 0.0 % 0.0 % 0.0 %
coverage
1  
2   #region Apache Notice
3   /*****************************************************************************
4   * $Header: $
5   * $Revision: $
6   * $Date: $
7   *
8   * iBATIS.NET Data Mapper
9   * Copyright (C) 2004 - Gilles Bayon
10   *
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   * http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License.
23   *
24   ********************************************************************************/
25   #endregion
26  
27   #region Imports
28   using System;
29   using System.Collections;
30   using System.Collections.Specialized;
31  
32   using IBatisNet.DataMapper.Configuration.Cache;
33   #endregion
34  
35   namespace IBatisNet.DataMapper.Configuration.Cache.Lru
36   {
37   /// <summary>
38   /// Summary description for LruCacheController.
39   /// </summary>
40   public class LruCacheController : ICacheController
41   {
42   #region Fields
43   private int _cacheSize = 0;
44   private Hashtable _cache = null;
45   private IList _keyList = null;
46   #endregion
47  
48   #region Constructor (s) / Destructor
49   /// <summary>
50   ///
51   /// </summary>
52 0 public LruCacheController()
53   {
54   _cacheSize = 100;
55   _cache = new Hashtable();
56   _keyList = new ArrayList();
57   }
58   #endregion
59  
60   #region ICacheController Members
61  
62   /// <summary>
63   /// Clears all elements from the cache.
64   /// </summary>
65 0 public void Flush()
66   {
67   lock(this)
68   {
69   _cache.Clear();
70   _keyList.Clear();
71   }
72   }
73  
74  
75   /// <summary>
76   /// Adds an item with the specified key and value into cached data.
77   /// Gets a cached object with the specified key.
78   /// </summary>
79   /// <value>The cached object or <c>null</c></value>
80 0 public object this [object key]
81   {
82   get
83   {
84   lock (this)
85   {
86   _keyList.Remove(key);
87   _keyList.Add(key);
88   return _cache[key];
89   }
90   }
91   set
92   {
93   lock (this)
94   {
95   _cache.Add(key, value);
96   _keyList.Add(key);
97   if (_keyList.Count > _cacheSize)
98   {
99   object oldestKey = _keyList[0];
100   _keyList.Remove(0);
101   _cache.Remove(oldestKey);
102   }
103   }
104   }
105   }
106  
107  
108   /// <summary>
109   /// Configures the cache
110   /// </summary>
111 0 public void Configure(HybridDictionary properties)
112   {
113   string size = (string)properties["CacheSize"];;
114   if (size != null)
115   {
116   _cacheSize = System.Convert.ToInt32(size);
117   }
118   }
119  
120   #endregion
121   }
122   }
123