]> granicus.if.org Git - apache/commitdiff
cache now can cache things for minutes.
authorIan Holsman <ianh@apache.org>
Fri, 4 Jan 2002 17:58:36 +0000 (17:58 +0000)
committerIan Holsman <ianh@apache.org>
Fri, 4 Jan 2002 17:58:36 +0000 (17:58 +0000)
add remove_entity function to type on mem_cache (so we can remove items from the cache)
PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92734 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/cache_storage.c
modules/experimental/mod_cache.c
modules/experimental/mod_cache.h
modules/experimental/mod_mem_cache.c
modules/experimental/mod_mem_cache.dsp

index eaffe85555fab84fcdddbbf3d7603f40c1ca7969..93c456dbd297d890cf696aa072bbcd2eef580d7a 100644 (file)
@@ -173,11 +173,9 @@ int cache_select_url(request_rec *r, const char *types, char *url)
              */
 
             /* Has the cache entry expired? */
-#if 0
             if (r->request_time > info->expire)
                 cache->fresh = 0;
             else
-#endif
                 cache->fresh = 1;
 
             /*** do content negotiation here */
index d3316668c5aaf831d787b98657636ebd529222fb..aa30a3b7d247aca4cc2e00abf488eef5df13685d 100644 (file)
@@ -591,6 +591,9 @@ int ap_cache_in_filter(ap_filter_t *f, apr_bucket_brigade *in)
                      "cache: Added date header");
         info->date = date;
     }
+    else {
+        date = info->date;
+    }
 
     /* set response_time for HTTP/1.1 age calculations */
     info->response_time = now;
@@ -622,7 +625,7 @@ int ap_cache_in_filter(ap_filter_t *f, apr_bucket_brigade *in)
     if (exp == APR_DATE_BAD) {
         if (lastmod != APR_DATE_BAD) {
             double x = (double) (date - lastmod) * conf->factor;
-            double maxex = conf->maxex;
+            double maxex = (double)conf->maxex;
             if (x > maxex)
                 x = maxex;
             exp = now + (int) x;
@@ -742,6 +745,18 @@ static const char
     conf->maxex_set = 1;
     return NULL;
 }
+static const char
+*set_cache_maxex_min(cmd_parms *parms, void *dummy, const char *arg)
+{
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
+    long val;
+
+    val = atol(arg);
+
+    conf->maxex = (apr_time_t) (val * MSEC_ONE_MIN);
+    conf->maxex_set = 1;
+    return NULL;
+}
 
 static const char
 *set_cache_defex(cmd_parms *parms, void *dummy, const char *arg)
@@ -755,6 +770,18 @@ static const char
     conf->defex_set = 1;
     return NULL;
 }
+static const char
+*set_cache_defex_min(cmd_parms *parms, void *dummy, const char *arg)
+{
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
+    long val;
+
+    val = atol(arg);
+
+    conf->defex = (apr_time_t) (val * MSEC_ONE_MIN);
+    conf->defex_set = 1;
+    return NULL;
+}
 
 static const char
 *set_cache_factor(cmd_parms *parms, void *dummy, const char *arg)
@@ -801,8 +828,14 @@ static const command_rec cache_cmds[] =
      "A partial URL prefix below which caching is disabled"),
     AP_INIT_TAKE1("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF,
      "The maximum time in hours to cache a document"),
-    AP_INIT_TAKE1("CacheDefaultExpire", set_cache_defex, NULL, RSRC_CONF,
+    AP_INIT_TAKE1("CacheMaxExpireMin", set_cache_maxex_min, NULL, RSRC_CONF,
+     "The maximum time in Minutes to cache a document"),
+
+     AP_INIT_TAKE1("CacheDefaultExpire", set_cache_defex, NULL, RSRC_CONF,
      "The default time in hours to cache a document"),
+     AP_INIT_TAKE1("CacheDefaultExpireMin", set_cache_defex_min, NULL, RSRC_CONF,
+     "The default time in Minutes to cache a document"),
+
     AP_INIT_TAKE1("CacheLastModifiedFactor", set_cache_factor, NULL, RSRC_CONF,
      "The factor used to estimate Expires date from LastModified date"),
     AP_INIT_TAKE1("CacheForceCompletion", set_cache_complete, NULL, RSRC_CONF,
index d357f77746efa9a005fc5545f6202563b4d6518a..1afa94a061973b2a4929112b41bcb8da8544995b 100644 (file)
 
 #define MSEC_ONE_DAY ((apr_time_t)(86400*APR_USEC_PER_SEC)) /* one day, in microseconds */
 #define MSEC_ONE_HR  ((apr_time_t)(3600*APR_USEC_PER_SEC))  /* one hour, in microseconds */
-
+#define MSEC_ONE_MIN  ((apr_time_t)(60*APR_USEC_PER_SEC))   /* one minute, in microseconds */
 #define DEFAULT_CACHE_MAXEXPIRE MSEC_ONE_DAY
 #define DEFAULT_CACHE_EXPIRE    MSEC_ONE_HR
 #define DEFAULT_CACHE_LMFACTOR (0.1)
index b4683e41dde3f55c929a5f4447edacaceff8bfe8..9b5cf5fe5c9c2b6f520e631454a8c80e20795258 100644 (file)
@@ -291,6 +291,7 @@ static int create_entity(cache_handle_t *h, const char *type, char *key, apr_siz
     h->read_headers = &read_headers;
     h->write_body = &write_body;
     h->write_headers = &write_headers;
+    h->remove_entity = &remove_entity;
 
     return OK;
 }
@@ -320,6 +321,7 @@ static int open_entity(cache_handle_t *h, const char *type, char *key)
     h->read_headers = &read_headers;
     h->write_body = &write_body;
     h->write_headers = &write_headers;
+    h->remove_entity = &remove_entity;
     h->cache_obj = obj;
 
     return OK;
index bbc9129134b55f713f2af53f09d4345e16b16a1c..ca8999bf049491f81935e2f156f60cd7d6ca734f 100644 (file)
@@ -69,7 +69,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "mod_mem_cache_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../srclib/apr-util/include" /I "../../srclib/apr/include" /I "../../include" /I "../../os/win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../srclib/apr-util/include" /I "../../srclib/apr/include" /I "../../include" /I "../../os/win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x409 /d "_DEBUG"