Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cache_mem/cache_dir options configurable #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 16 additions & 6 deletions src/overlord/Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class DutConfig {
this._dedicatedWorkerPorts = false; // one listening port per worker
this._memoryCaching = false;
this._diskCaching = false;
this._diskCachingOptions = null;
this._memoryCachingOptions = null;
this._collapsedForwarding = false;
this._listeningPorts = [];
this._customDirectives = [];
Expand All @@ -72,16 +74,20 @@ export class DutConfig {
this._dedicatedWorkerPorts = enable;
}

memoryCaching(enable) {
assert.strictEqual(arguments.length, 1);
memoryCaching(enable, memoryOptions) {
assert(arguments.length == 1 || arguments.length == 2);
assert(enable !== undefined); // for now; can be used for default mode later
this._memoryCaching = enable;
if (memoryOptions !== undefined)
this._memoryCachingOptions = memoryOptions;
}

diskCaching(enable) {
assert.strictEqual(arguments.length, 1);
diskCaching(enable, diskOptions) {
assert(arguments.length == 1 || arguments.length == 2);
assert(enable !== undefined); // for now; can be used for default mode later
this._diskCaching = enable;
if (diskOptions !== undefined)
this._diskCachingOptions = diskOptions;
}

collapsedForwarding(enable) {
Expand Down Expand Up @@ -188,9 +194,12 @@ export class DutConfig {
}

_memoryCachingCfg() {
const cacheSize = this._memoryCaching ? "100 MB" : "0";
let opts = "0"; // cache size
if (this._memoryCaching) {
opts = this._memoryCachingOptions === null ? "100 MB" : this._memoryCachingOptions;
}
let cfg = `
cache_mem ${cacheSize}
cache_mem ${opts}
`;
return this._trimCfg(cfg);
}
Expand All @@ -200,6 +209,7 @@ export class DutConfig {
return '';

const kid = "kid${process_number}";
const opts = this._diskCachingOptions === null ? '100' : this._diskCachingOptions;
const cfg = `
cache_dir rock /usr/local/squid/var/cache/overlord/rock 100
cache_store_log stdio:store-${kid}.log
Expand Down