table.lookup_integer

INTEGERtable.lookup_integerIDidSTRINGkeyINTEGERdefault

Available inall subroutines.

Looks up the key key in the table id. When the key is present, its associated value will be returned. When the key is absent, the default value is returned. The default value is required.

Example

backend prod { .host = "203.0.113.0"; }
backend beta { .host = "203.0.113.1"; }
table percent_for_beta INTEGER {
"a.example.com": 50,
"b.example.com": 20,
"c.example.com": 80,
}
sub vcl_recv {
if (randomint(0, 99) < table.lookup_integer(percent_for_beta, req.http.host, 0)) {
set req.backend = beta;
} else {
set req.backend = prod;
}
}