-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDataCacheFactory.cs
More file actions
67 lines (56 loc) · 1.82 KB
/
Copy pathDataCacheFactory.cs
File metadata and controls
67 lines (56 loc) · 1.82 KB
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
using System;
using System.Configuration;
namespace Alachisoft.NCache.Data.Caching
{
public sealed class DataCacheFactory : IDisposable
{
private readonly DataCacheFactoryConfiguration _configuration;
private static bool expirable;
private static TimeSpan defaultTTL;
private static string defaultCache;
static DataCacheFactory()
{
var result = bool.TryParse(ConfigurationManager.AppSettings["Expirable"], out bool expirable1);
if (result)
{
expirable = expirable1;
}
else
{
expirable = true;
}
result = TimeSpan.TryParse(ConfigurationManager.AppSettings["TTL"], out TimeSpan timeOut);
if (result)
{
if (timeOut <= TimeSpan.Zero)
{
throw new ArgumentException("Time-out should be a positive value in the application configuration file.");
}
defaultTTL = timeOut;
}
else
{
defaultTTL = new TimeSpan(0, 10, 0);
}
defaultCache = ConfigurationManager.AppSettings["Default"];
}
public DataCacheFactory()
{
}
public DataCacheFactory(DataCacheFactoryConfiguration configuration)
{
_configuration = configuration.Clone() as DataCacheFactoryConfiguration;
}
public DataCache GetCache(string cacheName)
{
return new DataCache(cacheName, _configuration, expirable, defaultTTL);
}
public DataCache GetDefaultCache()
{
return new DataCache(defaultCache, null, true, new TimeSpan(0, 10, 0));
}
public void Dispose()
{
}
}
}