forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashtableCache.cs
72 lines (60 loc) · 1.13 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
using System;
using System.Collections;
using System.Runtime.CompilerServices;
namespace NHibernate.Cache {
/// <summary>
/// A simple <c>Hashtable</c> based cache
/// </summary>
public class HashtableCache : ICache
{
private static object synchObject = new object();
private Hashtable cache = new Hashtable();
private string region;
public HashtableCache(string region)
{
this.region = region;
}
#region ICache Members
public object Get(object key)
{
return cache[key];
}
public void Put(object key, object value)
{
cache[key] = value;
}
public void Remove(object key)
{
cache.Remove(key);
}
public void Clear()
{
cache.Clear();
}
/// <summary>
/// Destroys the existing cache by setting it to a new Hashtable.
/// </summary>
public void Destroy()
{
cache = new Hashtable();
}
public string Region
{
set { region = value; }
}
// were added in h2.1
// public void Lock( object key )
// {
// }
//
// public void Unlock( object key )
// {
// }
//
// public long NextTimestamp()
// {
// return Timestamper.Next();
// }
#endregion
}
}