forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashtableCache.cs
83 lines (69 loc) · 1.32 KB
/
HashtableCache.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
using System.Collections;
namespace NHibernate.Cache
{
/// <summary>
/// A simple <c>Hashtable</c> based cache
/// </summary>
public class HashtableCache : ICache
{
private IDictionary hashtable = new Hashtable();
private readonly string regionName;
#region ICache Members
public HashtableCache(string regionName)
{
this.regionName = regionName;
}
/// <summary></summary>
public object Get( object key )
{
return hashtable[ key ];
}
/// <summary></summary>
public void Put( object key, object value )
{
hashtable[ key ] = value;
}
/// <summary></summary>
public void Remove( object key )
{
hashtable.Remove( key );
}
/// <summary></summary>
public void Clear()
{
hashtable.Clear();
}
/// <summary></summary>
public void Destroy()
{
}
/// <summary></summary>
public void Lock( object key )
{
// local cache, so we use synchronization
}
/// <summary></summary>
public void Unlock( object key )
{
// local cache, so we use synchronization
}
/// <summary></summary>
public long NextTimestamp()
{
return Timestamper.Next();
}
/// <summary></summary>
public int Timeout
{
get
{
return Timestamper.OneMs * 60000; // ie. 60 seconds
}
}
public string RegionName
{
get { return regionName; }
}
#endregion
}
}