Table
Atable declaration creates a key-value store in VCL code. Table keys are always of typeSTRING, and values may be one of a number of VCL types, but must all be of the same type within the same table.
Tables may be declared using VCL, but can also be created via anAPI call, using the CLI, or using theweb interface.
HINT: Tables created via API, CLI, or web interface are calleddictionaries and are dynamic (i.e., the items in the dictionary may be changed without cloning and activating a new version of your service).
Syntax
The following examples shows the syntax of aSTRING table:
table redirects {"/old/path":"https://other.hostname/new/path","/another/path":"/new/path",}Thetable.contains function will return aBOOL indicating whether a specified key is in the table.
ForSTRING tables, thetable.lookup function returns the value for a specified key, or a fallback value if the key is not present in the table.
Either short- or long-form strings are supported for keys and for valuesusingSTRING literals.
A trailing comma after the final value is optional, but supported.
Type variations
Table declarations support a type specifier and valid types areSTRING (the default),ACL,BACKEND,BOOL,FLOAT,INTEGER,IP,REGEX, andRTIME. All values within the same table are of the same type.
A typed table is declared like this:
table routing_tableBACKEND {"a.example.com": b0,"b.example.com": b1,"c.example.com": b2,}The syntax for values differs for each type.
The optionaltype for values,defaults to STRING when not specified.
The following functions return values from typed tables:
table.lookup_acltable.lookup_backendtable.lookup_booltable.lookup_floattable.lookup_integertable.lookup_iptable.lookup_regextable.lookup_rtime
Usage
Redirects are a very common use case for tables:
Limitations
The number of items in a single table is limited to 1000 by default, but larger tables are common. If you need a larger limit than the default, get in touch withFastly support and we'll be glad to assist you.