Anonymous avatar Anonymous committed b4810f7

Issue number: CACHE-228 CRON expressionsto expire content at specific dates and/or times
Obtained from: Lars Torunski

Comments (0)

Files changed (1)

src/java/com/opensymphony/oscache/web/filter/CacheFilter.java

     private int cacheScope = PageContext.APPLICATION_SCOPE; // filter scope - default is APPLICATION
     private int fragment = FRAGMENT_AUTODETECT; // defines if this filter handles fragments of a page - default is auto detect
     private int time = 60 * 60; // time before cache should be refreshed - default one hour (in seconds)
+    private String cron = null; // A cron expression that determines when this cached content will expire - default is null
     private int nocache = NOCACHE_OFF; // defines special no cache option for the requests - default is off
     private long lastModified = LAST_MODIFIED_INITIAL; // defines if the last-modified-header will be sent - default is intial setting
     private long expires = EXPIRES_ON; // defines if the expires-header will be sent - default is on
         String key = cacheKeyProvider.createCacheKey(httpRequest, admin, cache);
 
         try {
-            ResponseContent respContent = (ResponseContent) cache.getFromCache(key, time);
+            ResponseContent respContent = (ResponseContent) cache.getFromCache(key, time, cron);
 
             if (log.isInfoEnabled()) {
                 log.info("<cache>: Using cached entry for " + key);
             log.info("Could not get init parameter 'scope', defaulting to 'application'.");
         }
 
+        // filter parameter cron
+        cron = config.getInitParameter("cron");
+
         // filter parameter fragment
         try {
             String fragmentString = config.getInitParameter("fragment");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.