Scroll to navigation

VMOD_VAR(3) VMOD_VAR(3)

NAME

vmod_var - Variable support for Varnish VCL

SYNOPSIS

import var [from "path"] ;

This VMOD implements basic variable support in VCL.

It supports strings, integers and real numbers. There are methods to get and set each data type.

Global variables have a lifespan that extends across requests and VCLs, for as long as the vmod is loaded.

The remaining functions have PRIV_TASK lifespan and are local to a single request or backend request.

CONTENTS

  • func_clear
  • func_get
  • func_get_duration
  • func_get_int
  • func_get_ip
  • func_get_real
  • func_get_string
  • func_global_get
  • func_global_set
  • func_set
  • func_set_duration
  • func_set_int
  • func_set_ip
  • func_set_real
  • func_set_string

set

VOID set(PRIV_TASK, STRING key, STRING value)


Set key to value.

get

STRING get(PRIV_TASK, STRING)


Get key with data type STRING. If stored key is not a STRING an empty string is returned.

global_set

VOID global_set(STRING, STRING)


global_get

STRING global_get(STRING)


set_int

VOID set_int(PRIV_TASK, STRING key, INT value)


Set key to value.

get_int

INT get_int(PRIV_TASK, STRING key)


Get key with data type INT. If stored key is not an INT zero will be returned.

set_string

VOID set_string(PRIV_TASK, STRING key, STRING value)


Identical to set().

get_string

STRING get_string(PRIV_TASK, STRING key)


Identical to get().

set_real

VOID set_real(PRIV_TASK, STRING key, REAL value)


Set key to value.

get_real

REAL get_real(PRIV_TASK, STRING key)


Get key with data type REAL. If stored key is not a REAL zero will be returned.

set_duration

VOID set_duration(PRIV_TASK, STRING key, DURATION value)


Set key to value.

get_duration

DURATION get_duration(PRIV_TASK, STRING key)


Get key with data type DURATION. If stored key is not a DURATION zero will be returned.

set_ip

VOID set_ip(PRIV_TASK, STRING key, IP value)


Set key to value.

get_ip

IP get_ip(PRIV_TASK, STRING key)


Get key with data type IP. If stored key is not an IP null will be returned.

clear

VOID clear(PRIV_TASK)


Clear all non-global variables.