cached.ml
let main() =
let (opt_list, cmdline_cfg) = Netplex_main.args() in
Arg.parse
opt_list
(fun s -> raise (Arg.Bad ("Don't know what to do with: " ^ s)))
"usage: cached [options]";
Sys.set_signal Sys.sigpipe Sys.Signal_ignore;
let factory() =
Cache_plex.factory
~name:"cached" (* Identifier can be freely chosen *)
~post_start_hook:(fun cache cont ->
(* Tune O'Caml GC *)
let ctrl = Gc.get() in
Gc.set { ctrl with
Gc.minor_heap_size = 128 * 1024;
Gc.space_overhead = 10;
Gc.max_overhead = 100;
}
)
()
in
Netplex_main.startup
( Netplex_mp.mp() ) (* multi-processing *)
Netplex_log.logger_factories (* allow all built-in logging styles *)
Netplex_workload.workload_manager_factories (* ... all ways of workload management *)
[ factory ()]
cmdline_cfg
;;
main();;
cached.conf
netplex {
controller {
max_level = "debug";
logging {
type = "stderr";
}
};
service {
name = "cached"; (* Identifier can be freely chosen *)
protocol {
name = "cached";
address {
type = "internet";
bind = "0.0.0.0:3333";
};
};
processor {
type = "cached"; (* Identifier must match the name argument of the factory *)
cache_directory = "/tmp/cached";
cache_max_size = 10000; (* in bytes *)
save_cache_period = 5; (* save every 5 seconds *)
save_cache_speed = 10000; (* limit speed to 10000 bytes/second *)
};
workload_manager { (* No other workload manager is allowed! *)
type = "constant";
threads = 1;
}
}
}