comparison src/global/WebCache.java @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:7ecd1a4ef557
1 package global;
2
3 import fschmidt.util.servlet.HttpCache;
4 import nabble.model.Init;
5
6
7 enum WebCache implements HttpCache {
8 INSTANCE;
9
10 private static final long hour = 1000L*60*60;
11 private static final long cacheTime = Init.get("cacheTime",hour);
12
13 private long mod = now();
14
15 private static long now() {
16 return System.currentTimeMillis()/1000*1000;
17 }
18
19 public synchronized long[] lastModifieds(String[] modifyingEvents) {
20 long now = now();
21 if( now - mod > cacheTime )
22 mod = now;
23 long[] rtn = new long[modifyingEvents.length];
24 for( int i=0; i<modifyingEvents.length; i++ ) {
25 rtn[i] = mod;
26 }
27 return rtn;
28 }
29
30 public void modified(String modifyingEvent) {
31 throw new UnsupportedOperationException();
32 }
33
34 public synchronized void clear() {
35 mod = now();
36 }
37
38 }