-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCacheManager.cs
114 lines (91 loc) · 2.77 KB
/
CacheManager.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
114
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Caching;
namespace Lu.Caching
{
public class CacheManager:ICache
{
private ICache _cache;
public CacheManager()
{
}
public CacheManager(ICache cache)
{
_cache = cache;
}
public ICache CacheInstance
{
get
{
return _cache == null ? _cache = new CachingProvider() : _cache;
}
}
public void AddItem(string key, object value, System.Runtime.Caching.CacheItemPolicy policy)
{
CacheInstance.AddItem(key, value, policy);
}
public void AddItem(string key, object value, DateTimeOffset dateTimeOffset)
{
CacheInstance.AddItem(key, value, dateTimeOffset);
}
public void AddItem(string key, object value)
{
CacheInstance.AddItem(key, value);
}
public object GetItem(string key)
{
return CacheInstance.GetItem(key);
}
public object GetItem(string key, bool remove)
{
return CacheInstance.GetItem(key, remove);
}
public T GetItem<T>(string key)
{
return CacheInstance.GetItem<T>(key);
}
public T GetItem<T>(string key, bool remove)
{
return CacheInstance.GetItem<T>(key, remove);
}
public void RemoveItem(string key)
{
CacheInstance.RemoveItem(key);
}
public Task<bool> AddItemAsync(string key, object value, CacheItemPolicy policy)
{
return CacheInstance.AddItemAsync(key, value, policy);
}
public Task<bool> AddItemAsync(string key, object value, DateTimeOffset dateTimeOffset)
{
return CacheInstance.AddItemAsync(key, value, dateTimeOffset);
}
public Task<bool> AddItemAsync(string key, object value)
{
return CacheInstance.AddItemAsync(key, value);
}
public Task<object> GetItemAsync(string key)
{
return CacheInstance.GetItemAsync(key);
}
public Task<object> GetItemAsync(string key, bool remove)
{
return CacheInstance.GetItemAsync(key,remove);
}
public Task<T> GetItemAsync<T>(string key)
{
return CacheInstance.GetItemAsync<T>(key);
}
public Task<T> GetItemAsync<T>(string key, bool remove)
{
return CacheInstance.GetItemAsync<T>(key,remove);
}
public Task<bool> RemoveItemAsync(string key)
{
return CacheInstance.RemoveItemAsync(key);
}
}
}