|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| package com.opensymphony.oscache.general; |
|
6 |
| |
|
7 |
| import com.opensymphony.oscache.base.*; |
|
8 |
| |
|
9 |
| import org.apache.commons.logging.Log; |
|
10 |
| import org.apache.commons.logging.LogFactory; |
|
11 |
| |
|
12 |
| import java.util.Date; |
|
13 |
| import java.util.Properties; |
|
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 |
| public class GeneralCacheAdministrator extends AbstractCacheAdministrator { |
|
79 |
| private static transient final Log log = LogFactory.getLog(GeneralCacheAdministrator.class); |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| private Cache applicationCache = null; |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
72
| public GeneralCacheAdministrator() {
|
|
90 |
72
| this(null);
|
|
91 |
| } |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
96
| public GeneralCacheAdministrator(Properties p) {
|
|
97 |
96
| super(p);
|
|
98 |
96
| log.info("Constructed GeneralCacheAdministrator()");
|
|
99 |
96
| createCache();
|
|
100 |
| } |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
4033041
| public Cache getCache() {
|
|
108 |
4033042
| return applicationCache;
|
|
109 |
| } |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
0
| public void removeEntry(String key) {
|
|
117 |
0
| getCache().removeEntry(key);
|
|
118 |
| } |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
8000
| public Object getFromCache(String key) throws NeedsRefreshException {
|
|
132 |
8000
| return getCache().getFromCache(key);
|
|
133 |
| } |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
| |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
2004368
| public Object getFromCache(String key, int refreshPeriod) throws NeedsRefreshException {
|
|
151 |
2004368
| return getCache().getFromCache(key, refreshPeriod);
|
|
152 |
| } |
|
153 |
| |
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
0
| public Object getFromCache(String key, int refreshPeriod, String cronExpression) throws NeedsRefreshException {
|
|
173 |
0
| return getCache().getFromCache(key, refreshPeriod, cronExpression);
|
|
174 |
| } |
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
2008109
| public void cancelUpdate(String key) {
|
|
184 |
2008109
| getCache().cancelUpdate(key);
|
|
185 |
| } |
|
186 |
| |
|
187 |
| |
|
188 |
| |
|
189 |
| |
|
190 |
4
| public void destroy() {
|
|
191 |
4
| finalizeListeners(applicationCache);
|
|
192 |
| } |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
0
| public void flushAll() {
|
|
200 |
0
| getCache().flushAll(new Date());
|
|
201 |
| } |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
0
| public void flushAll(Date date) {
|
|
209 |
0
| getCache().flushAll(date);
|
|
210 |
| } |
|
211 |
| |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
0
| public void flushEntry(String key) {
|
|
216 |
0
| getCache().flushEntry(key);
|
|
217 |
| } |
|
218 |
| |
|
219 |
| |
|
220 |
| |
|
221 |
| |
|
222 |
| |
|
223 |
| |
|
224 |
36
| public void flushGroup(String group) {
|
|
225 |
36
| getCache().flushGroup(group);
|
|
226 |
| } |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
| |
|
231 |
| |
|
232 |
| |
|
233 |
| |
|
234 |
| |
|
235 |
| |
|
236 |
24
| public void flushPattern(String pattern) {
|
|
237 |
24
| getCache().flushPattern(pattern);
|
|
238 |
| } |
|
239 |
| |
|
240 |
| |
|
241 |
| |
|
242 |
| |
|
243 |
| |
|
244 |
| |
|
245 |
| |
|
246 |
| |
|
247 |
12193
| public void putInCache(String key, Object content, EntryRefreshPolicy policy) {
|
|
248 |
12193
| Cache cache = getCache();
|
|
249 |
12192
| cache.putInCache(key, content, policy);
|
|
250 |
| } |
|
251 |
| |
|
252 |
| |
|
253 |
| |
|
254 |
| |
|
255 |
| |
|
256 |
| |
|
257 |
| |
|
258 |
12189
| public void putInCache(String key, Object content) {
|
|
259 |
12188
| putInCache(key, content, (EntryRefreshPolicy) null);
|
|
260 |
| } |
|
261 |
| |
|
262 |
| |
|
263 |
| |
|
264 |
| |
|
265 |
| |
|
266 |
| |
|
267 |
| |
|
268 |
| |
|
269 |
84
| public void putInCache(String key, Object content, String[] groups) {
|
|
270 |
84
| getCache().putInCache(key, content, groups);
|
|
271 |
| } |
|
272 |
| |
|
273 |
| |
|
274 |
| |
|
275 |
| |
|
276 |
| |
|
277 |
| |
|
278 |
| |
|
279 |
| |
|
280 |
| |
|
281 |
0
| public void putInCache(String key, Object content, String[] groups, EntryRefreshPolicy policy) {
|
|
282 |
0
| getCache().putInCache(key, content, groups, policy, null);
|
|
283 |
| } |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
| |
|
288 |
| |
|
289 |
| |
|
290 |
| |
|
291 |
| |
|
292 |
16
| public void setCacheCapacity(int capacity) {
|
|
293 |
16
| super.setCacheCapacity(capacity);
|
|
294 |
16
| getCache().setCapacity(capacity);
|
|
295 |
| } |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
| |
|
300 |
96
| private void createCache() {
|
|
301 |
96
| log.info("Creating new cache");
|
|
302 |
| |
|
303 |
96
| applicationCache = new Cache(isMemoryCaching(), isUnlimitedDiskCache(), isOverflowPersistence(), isBlocking(), algorithmClass, cacheCapacity);
|
|
304 |
| |
|
305 |
96
| configureStandardListeners(applicationCache);
|
|
306 |
| } |
|
307 |
| } |