]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Unify memory_cache_first/disk into a single memory_cache_mode directive
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Tue, 4 Aug 2009 02:07:56 +0000 (04:07 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Tue, 4 Aug 2009 02:07:56 +0000 (04:07 +0200)
src/cache_cf.cc
src/cf.data.depend
src/cf.data.pre

index eb54ce1c81ee65134dc3a98ae4d5f1b510fb4919..188a115ad39067b9c696f65938ade00742a53510 100644 (file)
@@ -2771,6 +2771,50 @@ dump_removalpolicy(StoreEntry * entry, const char *name, RemovalPolicySettings *
     storeAppendPrintf(entry, "\n");
 }
 
+static void
+free_memcachemode(SquidConfig * config)
+{
+    return;
+}
+
+static void
+parse_memcachemode(SquidConfig * config)
+{
+    char *token = strtok(NULL, w_space);
+    if (!token)
+       self_destruct();
+
+    if (strcmp(token, "always")) {
+       Config.onoff.memory_cache_first = 1;
+       Config.onoff.memory_cache_disk = 1;
+    } else if (strcmp(token, "disk")) {
+       Config.onoff.memory_cache_first = 0;
+       Config.onoff.memory_cache_disk = 1;
+    } else if (strncmp(token, "net", 3) == 0) {
+       Config.onoff.memory_cache_first = 1;
+       Config.onoff.memory_cache_disk = 0;
+    } else if (strncmp(token, "none", 3) == 0) {
+       Config.onoff.memory_cache_first = 0;
+       Config.onoff.memory_cache_disk = 0;
+    } else
+       self_destruct();
+}
+
+static void
+dump_memcachemode(StoreEntry * entry, const char *name, SquidConfig &config)
+{
+    storeAppendPrintf(entry, "%s ", name);
+    if (Config.onoff.memory_cache_first && Config.onoff.memory_cache_disk)
+       storeAppendPrintf(entry, "always");
+    else if (!Config.onoff.memory_cache_first && Config.onoff.memory_cache_disk)
+       storeAppendPrintf(entry, "disk");
+    else if (Config.onoff.memory_cache_first && !Config.onoff.memory_cache_disk)
+       storeAppendPrintf(entry, "network");
+    else if (!Config.onoff.memory_cache_first && !Config.onoff.memory_cache_disk)
+       storeAppendPrintf(entry, "none");
+    storeAppendPrintf(entry, "\n");
+}
+
 #include "cf_parser.h"
 
 peer_t
index 54b54ae8d53daa293c4b2c8aead5afc0c2c5234f..c09aa8749b2cd5235131ef727fae8968c7937b0e 100644 (file)
@@ -36,6 +36,7 @@ int
 kb_int64_t
 kb_size_t
 logformat
+memcachemode
 onoff
 peer
 peer_access            cache_peer acl
index 593f5cf85288cfceedfdc32dce8ac2dd41901ee5..f44871a8adf5e38ffdf9cd2aef1d535595f9e08b 100644 (file)
@@ -2084,24 +2084,20 @@ DOC_START
        enough to keep larger objects from hoarding cache_mem.
 DOC_END
 
-NAME: memory_cache_first
-TYPE: onoff
-LOC: Config.onoff.memory_cache_first
-DEFAULT: on
+NAME: memory_cache_mode
+TYPE: memcachemode
+LOC: Config
+DEFAULT: always
 DOC_START
-       Squid normally caches objects retreived from network into memory.
-       By setting this to off objects gets released from memory when
-       written to disk.
-DOC_END
+       Controls which objects to keep in the memory cache (cache_mem)
 
-NAME: memory_cache_disk
-TYPE: onoff
-LOC: Config.onoff.memory_cache_disk
-DEFAULT: on
-DOC_START
-       Squid normally keeps a copy of cache hit objects in memory as well
-       as on disk. By setting this to off cache hits to objects stored on
-       disk will not be read back into the memory cache.
+       always  Keep most recently fetched objects in memory (default)
+
+       disk    Only disk cache hits are kept in memory, which means
+               an object must first be cached on disk and then hit
+               a second time before cached in memory.
+
+       network Only objects fetched from network is kept in memory
 DOC_END
 
 NAME: memory_replacement_policy