Mercurial Hosting > nabble
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/global/WebCache.java Thu Mar 21 19:15:52 2019 -0600 @@ -0,0 +1,38 @@ +package global; + +import fschmidt.util.servlet.HttpCache; +import nabble.model.Init; + + +enum WebCache implements HttpCache { + INSTANCE; + + private static final long hour = 1000L*60*60; + private static final long cacheTime = Init.get("cacheTime",hour); + + private long mod = now(); + + private static long now() { + return System.currentTimeMillis()/1000*1000; + } + + public synchronized long[] lastModifieds(String[] modifyingEvents) { + long now = now(); + if( now - mod > cacheTime ) + mod = now; + long[] rtn = new long[modifyingEvents.length]; + for( int i=0; i<modifyingEvents.length; i++ ) { + rtn[i] = mod; + } + return rtn; + } + + public void modified(String modifyingEvent) { + throw new UnsupportedOperationException(); + } + + public synchronized void clear() { + mod = now(); + } + +}