Switch/Case statement?

Paul A. Procacci pprocacci at datapipe.com
Fri Dec 14 02:29:02 CET 2012

There is no switch/case in vcl.  Only if/elseif/else as you've already

VCL gets compiled to machine code via gcc.  The difference between
switch/case and if/elseif/else is only visual.  Both require branching.

In the optimization manual for intel cpu's it explains that you should
extract the case that is most likely going to be hit most often from the
switch statement, preceding the switch statement to avoid heavy branching.
This isn't any different than if/elseif/else.

In either case, this is neither here nor there.

Currently to my knowledge, you cannot dynamically assign backends.  This
has been discussed numerous times already on this list.  There are plans
from my reading to introduce such a thing, but isn't yet completed.

What you're currently doing is the only way atm to accomplish what you
want.  I'll beg others to correct this if there have been updates that
I am not aware of.

I would keep what you currently have:

>         if ( server.ip == "" ) {
>                 set req.backend = backend1;
>         } elsif ( server.ip == "" ) {
>                 set req.backend = backend2;

.... until a better alternative gets introduced.



This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.

More information about the varnish-misc mailing list