Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions plugins/experimental/cache_promote/cache_promote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "ts/remap.h"
#include "ts/ink_config.h"

#define DEFAULT_BUCKET_SIZE 10

static const char *PLUGIN_NAME = "cache_promote";
TSCont gNocacheCont;
Expand Down Expand Up @@ -138,8 +139,8 @@ class ChancePolicy : public PromotionPolicy


//////////////////////////////////////////////////////////////////////////////////////////////
// The LRU based policy keeps track of <bucket> number of URLs, with a counter for each slot.
// Objects are not promoted unless the counter reaches <hits> before it gets evicted. An
// The LRU basedo policy keeps track of <bucket> number of URLs, with a counter for each slot.
// Objects are not promted unless the counter reaches <hits> before it gets evicted. An
// optional <chance> parameter can be used to sample hits, this can reduce contention and
// churning in the LRU as well.
//
Expand Down Expand Up @@ -209,6 +210,12 @@ class LRUPolicy : public PromotionPolicy
switch (opt) {
case 'b':
_buckets = static_cast<unsigned>(strtol(optarg, NULL, 10));
if (_buckets <= 0) {
// buckets size of 0 doesn't make sense and is not supported. Set to default value of 10.
TSDebug(PLUGIN_NAME, "buckets size of 0 is not allowed. Use buckets size >= 10");
TSDebug(PLUGIN_NAME, "Setting to default bucket size of 10");
_buckets = DEFAULT_BUCKET_SIZE;
}
break;
case 'h':
_hits = static_cast<unsigned>(strtol(optarg, NULL, 10));
Expand Down Expand Up @@ -249,6 +256,7 @@ class LRUPolicy : public PromotionPolicy
map_it = _map.find(&hash);
if (_map.end() != map_it) {
// We have an entry in the LRU
TSReleaseAssert(_list.size() > 0); // mismatch in the LRUs hash and list
if (++(map_it->second->second) >= _hits) {
// Promoted! Cleanup the LRU, and signal success. Save the promoted entry on the freelist.
TSDebug(PLUGIN_NAME, "saving the LRUEntry to the freelist");
Expand Down