From: Henrik Nordstrom Date: Tue, 4 Aug 2009 02:07:56 +0000 (+0200) Subject: Unify memory_cache_first/disk into a single memory_cache_mode directive X-Git-Tag: SQUID_3_2_0_1~795^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea21d49788dbca1dfa77822fa736c79c813d5648;p=thirdparty%2Fsquid.git Unify memory_cache_first/disk into a single memory_cache_mode directive --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index eb54ce1c81..188a115ad3 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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 diff --git a/src/cf.data.depend b/src/cf.data.depend index 54b54ae8d5..c09aa8749b 100644 --- a/src/cf.data.depend +++ b/src/cf.data.depend @@ -36,6 +36,7 @@ int kb_int64_t kb_size_t logformat +memcachemode onoff peer peer_access cache_peer acl diff --git a/src/cf.data.pre b/src/cf.data.pre index 593f5cf852..f44871a8ad 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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