forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSecondLevelCacheStatistics.cs
113 lines (102 loc) · 2.24 KB
/
SecondLevelCacheStatistics.cs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections;
using System.Text;
using NHibernate.Cache;
namespace NHibernate.Stat
{
/// <summary> Second level cache statistics of a specific region </summary>
[Serializable]
public class SecondLevelCacheStatistics : CategorizedStatistics
{
[NonSerialized]
// 6.0 TODO: type as CacheBase instead
#pragma warning disable 618
private readonly ICache cache;
#pragma warning restore 618
internal long hitCount;
internal long missCount;
internal long putCount;
// 6.0 TODO: get as CacheBase instead
#pragma warning disable 618
public SecondLevelCacheStatistics(ICache cache) : base(cache.RegionName)
#pragma warning restore 618
{
this.cache = cache;
}
public long HitCount
{
get { return hitCount; }
}
public long MissCount
{
get { return missCount; }
}
public long PutCount
{
get { return putCount; }
}
/// <summary>
/// Not ported yet
/// </summary>
public long ElementCountInMemory
{
get
{
return -1; // cache.ElementCountInMemory;
}
}
/// <summary>
/// Not ported yet
/// </summary>
public long ElementCountOnDisk
{
get
{
return -1; // cache.ElementCountOnDisk;
}
}
/// <summary>
/// Not ported yet
/// </summary>
public long SizeInMemory
{
get
{
return -1; // cache.SizeInMemory;
}
}
/// <summary>
/// Not ported yet
/// </summary>
public IDictionary Entries
{
get
{
IDictionary map = new Hashtable();
//IDictionary<CacheKey, object> cacheMap = cache.ToMap();
//foreach (KeyValuePair<CacheKey, object> me in cacheMap)
//{
// map[me.Key.Key] = me.Value;
//}
return map;
}
}
public override string ToString()
{
StringBuilder buf = new StringBuilder()
.Append("SecondLevelCacheStatistics[")
.Append("hitCount=").Append(hitCount)
.Append(",missCount=").Append(missCount)
.Append(",putCount=").Append(putCount);
//not sure if this would ever be null but wanted to be careful
if (cache != null)
{
buf.Append(",elementCountInMemory=").Append(ElementCountInMemory)
.Append(",elementCountOnDisk=").Append(ElementCountOnDisk)
.Append(",sizeInMemory=").Append(SizeInMemory);
}
buf.Append(']');
return buf.ToString();
}
}
}