1 5 package com.opensymphony.oscache.web.filter; 6 7 import com.opensymphony.oscache.base.CacheEntry; 8 import com.opensymphony.oscache.base.EntryRefreshPolicy; 9 import com.opensymphony.oscache.base.NeedsRefreshException; 10 11 18 public class ExpiresRefreshPolicy implements EntryRefreshPolicy { 19 20 21 private long refreshPeriod; 22 23 28 public ExpiresRefreshPolicy(int refreshPeriod) { 29 this.refreshPeriod = refreshPeriod * 1000L; 30 } 31 32 44 public boolean needsRefresh(CacheEntry entry) { 45 46 long currentTimeMillis = System.currentTimeMillis(); 47 48 if ((refreshPeriod >= 0) && (currentTimeMillis >= (entry.getLastUpdate() + refreshPeriod))) { 49 return true; 50 } else if (entry.getContent() instanceof ResponseContent) { 51 ResponseContent responseContent = (ResponseContent) entry.getContent(); 52 return currentTimeMillis >= responseContent.getExpires(); 53 } else { 54 return false; 55 } 56 57 } 58 59 } 60 | Popular Tags |