]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/repl/heap/store_heap_replacement.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / repl / heap / store_heap_replacement.cc
index 3bf01d346866d57f546e48d7c21c03dd940a30ba..b005a45a773cdb7a5a511cbb40eac5681f764636 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_heap_replacement.cc,v 1.13 2003/09/29 10:24:00 robertc Exp $
+ * $Id$
  *
  * DEBUG: section 20    Storage Manager Heap-based replacement
  * AUTHOR: John Dilley
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -35,7 +35,7 @@
 
 /*
  * The code in this file is Copyrighted (C) 1999 by Hewlett Packard.
- * 
+ *
  *
  * For a description of these cache replacement policies see --
  *  http://www.hpl.hp.com/techreports/1999/HPL-1999-69.html
 #include "store_heap_replacement.h"
 #include "Store.h"
 #include "MemObject.h"
+#include "SquidTime.h"
+
+#if HAVE_MATH_H
+#include <math.h>
+#endif
 
 /*
  * Key generation function to implement the LFU-DA policy (Least
@@ -55,7 +60,7 @@
  * in cache regardless of size.  Achieves lower hit rate than GDS
  * because there are more large objects in cache (so less room for
  * smaller popular objects).
- * 
+ *
  * This version implements a tie-breaker based upon recency
  * (e->lastref): for objects that have the same reference count
  * the most recent object wins (gets a higher key value).
@@ -88,13 +93,11 @@ HeapKeyGen_StoreEntry_LFUDA(void *entry, double heap_age)
            " heap_age=" << heap_age << " tie=" << tie << " -> " << key);
 
     if (e->mem_obj && e->mem_obj->url)
-        debug(81, 3) ("HeapKeyGen_StoreEntry_LFUDA: url=%s\n",
-                      e->mem_obj->url);
+        debugs(81, 3, "HeapKeyGen_StoreEntry_LFUDA: url=" << e->mem_obj->url);
 
     return (double) key;
 }
 
-
 /*
  * Key generation function to implement the GDS-Frequency policy.
  * Similar to Greedy Dual-Size Hits policy, but adds aging of
@@ -102,7 +105,7 @@ HeapKeyGen_StoreEntry_LFUDA(void *entry, double heap_age)
  * keeping more small, popular objects in cache.  Achieves lower
  * byte hit rate than LFUDA because there are fewer large objects
  * in cache.
- * 
+ *
  * This version implements a tie-breaker based upon recency
  * (e->lastref): for objects that have the same reference count
  * the most recent object wins (gets a higher key value).
@@ -128,8 +131,7 @@ HeapKeyGen_StoreEntry_GDSF(void *entry, double heap_age)
            " -> " << key);
 
     if (e->mem_obj && e->mem_obj->url)
-        debug(81, 3) ("HeapKeyGen_StoreEntry_GDSF: url=%s\n",
-                      e->mem_obj->url);
+        debugs(81, 3, "HeapKeyGen_StoreEntry_GDSF: url=" << e->mem_obj->url);
 
     return key;
 }
@@ -145,12 +147,12 @@ heap_key
 HeapKeyGen_StoreEntry_LRU(void *entry, double heap_age)
 {
     StoreEntry *e = (StoreEntry *)entry;
-    debug(81, 3) ("HeapKeyGen_StoreEntry_LRU: %s heap_age=%f lastref=%f\n",
-                  e->getMD5Text(), heap_age, (double) e->lastref);
+    debugs(81, 3, "HeapKeyGen_StoreEntry_LRU: " <<
+           e->getMD5Text() << " heap_age=" << heap_age <<
+           " lastref=" << (double) e->lastref  );
 
     if (e->mem_obj && e->mem_obj->url)
-        debug(81, 3) ("HeapKeyGen_StoreEntry_LRU: url=%s\n",
-                      e->mem_obj->url);
+        debugs(81, 3, "HeapKeyGen_StoreEntry_LRU: url=" << e->mem_obj->url);
 
     return (heap_key) e->lastref;
 }