]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added squid.conf directives for tuning when objects gets cached into memory
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Wed, 29 Jul 2009 08:44:07 +0000 (10:44 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Wed, 29 Jul 2009 08:44:07 +0000 (10:44 +0200)
src/MemObject.cc
src/cf.data.pre
src/store_client.cc
src/structs.h

index 97493dd0891f8d594393797cf76be3ea29b57c52..0c588056c2825dab3f5c705690c1c57a51dce72f 100644 (file)
@@ -322,7 +322,8 @@ MemObject::policyLowestOffsetToKeep() const
     int64_t lowest_offset = lowestMemReaderOffset();
 
     if (endOffset() < lowest_offset ||
-            endOffset() - inmem_lo > (int64_t)Config.Store.maxInMemObjSize)
+            endOffset() - inmem_lo > (int64_t)Config.Store.maxInMemObjSize ||
+            !Config.onoff.memory_cache_first)
         return lowest_offset;
 
     return inmem_lo;
index 62c9cc0d00b1dc620222ad91ac5e10e2f994efe1..593f5cf85288cfceedfdc32dce8ac2dd41901ee5 100644 (file)
@@ -2084,6 +2084,26 @@ 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
+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
+
+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.
+DOC_END
+
 NAME: memory_replacement_policy
 TYPE: removalpolicy
 LOC: Config.memPolicy
index b98c8ff21c45f61aa85c58caf07f401efb8a7b6c..61d18f8f5a3d7a851c978d6e878f0a74c7d066a5 100644 (file)
@@ -499,7 +499,7 @@ store_client::readBody(const char *buf, ssize_t len)
     }
 
     const HttpReply *rep = entry->getReply();
-    if (len > 0 && rep && entry->mem_obj->inmem_lo == 0 && entry->objectLen() <= (int64_t)Config.Store.maxInMemObjSize) {
+    if (len > 0 && rep && entry->mem_obj->inmem_lo == 0 && entry->objectLen() <= (int64_t)Config.Store.maxInMemObjSize && Config.onoff.memory_cache_disk) {
         storeGetMemSpace(len);
         // The above may start to free our object so we need to check again
         if (entry->mem_obj->inmem_lo == 0) {
index 198f35eb8210ed527425eab4fa0bfa97fecf6c62..fd9941d9ec34cec5b63387cba84d8acca6d2191b 100644 (file)
@@ -444,6 +444,8 @@ struct SquidConfig {
 #endif /* FOLLOW_X_FORWARDED_FOR */
 
         int WIN32_IpAddrChangeMonitor;
+        int memory_cache_first;
+        int memory_cache_disk;
     } onoff;
 
     int forward_max_tries;