Varnish

目录

简介

类摘要

VarnishAdmin

class VarnishAdmin {

/* 方法 */

public bool auth ( void )

public int ban ( string $vcl_regex )

public int banUrl ( string $vcl_regex )

public int clearPanic ( void )

public bool connect ( void )

public __construct ([ array $args ] )

public bool disconnect ( void )

public string getPanic ( void )

public array getParams ( void )

public bool isRunning ( void )

public void setCompat ( int $compat )

public void setHost ( string $host )

public void setIdent ( string $ident )

public int setParam ( string $name , string|integer $value )

public void setPort ( int $port )

public void setSecret ( string $secret )

public void setTimeout ( int $timeout )

public int start ( void )

public int stop ( void )

}

VarnishAdmin::auth

Authenticate on a varnish instance

说明

public bool VarnishAdmin::auth ( void )

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

VarnishAdmin::ban

Ban URLs using a VCL expression

说明

public int VarnishAdmin::ban ( string $vcl_regex )

参数

vcl_regex
Varnish VCL expression. It's based on the varnish ban command.

返回值

Returns the varnish command status.

VarnishAdmin::banUrl

Ban an URL using a VCL expression

说明

public int VarnishAdmin::banUrl ( string $vcl_regex )

参数

vcl_regex
URL regular expression in PCRE compatible syntax. It's based on the ban.url varnish command.

返回值

Returns the varnish command status.

VarnishAdmin::clearPanic

Clear varnish instance panic messages

说明

public int VarnishAdmin::clearPanic ( void )

参数

此函数没有参数。

返回值

Returns the varnish command status.

VarnishAdmin::connect

Connect to a varnish instance administration interface

说明

public bool VarnishAdmin::connect ( void )

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

VarnishAdmin::__construct

VarnishAdmin constructor

说明

public VarnishAdmin::__construct ([ array $args ] )

参数

args
Configuration arguments. The possible keys are:

VARNISH_CONFIG_IDENT - local varnish instance ident
VARNISH_CONFIG_HOST - varnish instance ip
VARNISH_CONFIG_PORT - varnish instance port
VARNISH_CONFIG_SECRET - varnish instance secret
VARNISH_CONFIG_TIMEOUT - connection read timeout
VARNISH_CONFIG_COMPAT - varnish major version compatibility

返回值

范例

示例 #1 VarnishAdmin::__construct example

<?php
    $args = array(
        VARNISH_CONFIG_HOST => "::1",
        VARNISH_CONFIG_PORT => 6082,
        VARNISH_CONFIG_SECRET => "5174826b-8595-4958-aa7a-0609632ad7ca",
        VARNISH_CONFIG_TIMEOUT => 300,
    );
    $va = new VarnishAdmin($args);
?>

VarnishAdmin::disconnect

Disconnect from a varnish instance administration interface

说明

public bool VarnishAdmin::disconnect ( void )

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

VarnishAdmin::getPanic

Get the last panic message on a varnish instance

说明

public string VarnishAdmin::getPanic ( void )

参数

此函数没有参数。

返回值

Returns the last panic message on the current varnish instance.

VarnishAdmin::getParams

Fetch current varnish instance configuration parameters

说明

public array VarnishAdmin::getParams ( void )

参数

此函数没有参数。

返回值

Returns an array with the varnish configuration parameters.

VarnishAdmin::isRunning

Check if the varnish slave process is currently running

说明

public bool VarnishAdmin::isRunning ( void )

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

VarnishAdmin::setCompat

Set the class compat configuration param

说明

public void VarnishAdmin::setCompat ( int $compat )

参数

compat
Varnish compatibility option.

返回值

VarnishAdmin::setHost

Set the class host configuration param

说明

public void VarnishAdmin::setHost ( string $host )

参数

host
Connection host configuration parameter.

返回值

VarnishAdmin::setIdent

Set the class ident configuration param

说明

public void VarnishAdmin::setIdent ( string $ident )

参数

ident
Connection ident configuration parameter.

返回值

VarnishAdmin::setParam

Set configuration param on the current varnish instance

说明

public int VarnishAdmin::setParam ( string $name , string|integer $value )

参数

name
Varnish configuration param name.

value
Varnish configuration param value.

返回值

Returns the varnish command status.

VarnishAdmin::setPort

Set the class port configuration param

说明

public void VarnishAdmin::setPort ( int $port )

参数

port
Connection port configuration parameter.

返回值

VarnishAdmin::setSecret

Set the class secret configuration param

说明

public void VarnishAdmin::setSecret ( string $secret )

参数

secret
Connection secret configuration parameter.

返回值

VarnishAdmin::setTimeout

Set the class timeout configuration param

说明

public void VarnishAdmin::setTimeout ( int $timeout )

参数

timeout
Connection timeout configuration parameter.

返回值

VarnishAdmin::start

Start varnish worker process

说明

public int VarnishAdmin::start ( void )

参数

此函数没有参数。

返回值

Returns the varnish command status.

VarnishAdmin::stop

Stop varnish worker process

说明

public int VarnishAdmin::stop ( void )

参数

此函数没有参数。

返回值

Returns the varnish command status.

简介

类摘要

VarnishStat

class VarnishStat {

/* 方法 */

public __construct ([ array $args ] )

public array getSnapshot ( void )

}

VarnishStat::__construct

VarnishStat constructor

说明

public VarnishStat::__construct ([ array $args ] )

参数

args
Configuration arguments. The possible keys are:

VARNISH_CONFIG_IDENT - local varnish instance ident path

返回值

VarnishStat::getSnapshot

Get the current varnish instance statistics snapshot

说明

public array VarnishStat::getSnapshot ( void )

参数

此函数没有参数。

返回值

Array with the varnish statistic snapshot. The array keys are identical to that in the varnishstat tool.

简介

类摘要

VarnishLog

class VarnishLog {

/* Constants */

const integer VarnishLog::TAG_Debug = 0 ;

const integer VarnishLog::TAG_Error = 1 ;

const integer VarnishLog::TAG_CLI = 2 ;

const integer VarnishLog::TAG_StatSess = 3 ;

const integer VarnishLog::TAG_ReqEnd = 4 ;

const integer VarnishLog::TAG_SessionOpen = 5 ;

const integer VarnishLog::TAG_SessionClose = 6 ;

const integer VarnishLog::TAG_BackendOpen = 7 ;

const integer VarnishLog::TAG_BackendXID = 8 ;

const integer VarnishLog::TAG_BackendReuse = 9 ;

const integer VarnishLog::TAG_BackendClose = 10 ;

const integer VarnishLog::TAG_HttpGarbage = 11 ;

const integer VarnishLog::TAG_Backend = 12 ;

const integer VarnishLog::TAG_Length = 13 ;

const integer VarnishLog::TAG_FetchError = 14 ;

const integer VarnishLog::TAG_RxRequest = 15 ;

const integer VarnishLog::TAG_RxResponse = 16 ;

const integer VarnishLog::TAG_RxStatus = 17 ;

const integer VarnishLog::TAG_RxURL = 18 ;

const integer VarnishLog::TAG_RxProtocol = 19 ;

const integer VarnishLog::TAG_RxHeader = 20 ;

const integer VarnishLog::TAG_TxRequest = 21 ;

const integer VarnishLog::TAG_TxResponse = 22 ;

const integer VarnishLog::TAG_TxStatus = 23 ;

const integer VarnishLog::TAG_TxURL = 24 ;

const integer VarnishLog::TAG_TxProtocol = 25 ;

const integer VarnishLog::TAG_TxHeader = 26 ;

const integer VarnishLog::TAG_ObjRequest = 27 ;

const integer VarnishLog::TAG_ObjResponse = 28 ;

const integer VarnishLog::TAG_ObjStatus = 29 ;

const integer VarnishLog::TAG_ObjURL = 30 ;

const integer VarnishLog::TAG_ObjProtocol = 31 ;

const integer VarnishLog::TAG_ObjHeader = 32 ;

const integer VarnishLog::TAG_LostHeader = 33 ;

const integer VarnishLog::TAG_TTL = 34 ;

const integer VarnishLog::TAG_Fetch_Body = 35 ;

const integer VarnishLog::TAG_VCL_acl = 36 ;

const integer VarnishLog::TAG_VCL_call = 37 ;

const integer VarnishLog::TAG_VCL_trace = 38 ;

const integer VarnishLog::TAG_VCL_return = 39 ;

const integer VarnishLog::TAG_VCL_error = 40 ;

const integer VarnishLog::TAG_ReqStart = 41 ;

const integer VarnishLog::TAG_Hit = 42 ;

const integer VarnishLog::TAG_HitPass = 43 ;

const integer VarnishLog::TAG_ExpBan = 44 ;

const integer VarnishLog::TAG_ExpKill = 45 ;

const integer VarnishLog::TAG_WorkThread = 46 ;

const integer VarnishLog::TAG_ESI_xmlerror = 47 ;

const integer VarnishLog::TAG_Hash = 48 ;

const integer VarnishLog::TAG_Backend_health = 49 ;

const integer VarnishLog::TAG_VCL_Log = 50 ;

const integer VarnishLog::TAG_Gzip = 51 ;

/* 方法 */

public __construct ([ array $args ] )

public array getLine ( void )

public static string getTagName ( int $index )

}

预定义常量

VarnishLog::TAG_Debug

VarnishLog::TAG_Error

VarnishLog::TAG_CLI

VarnishLog::TAG_StatSess

VarnishLog::TAG_ReqEnd

VarnishLog::TAG_SessionOpen

VarnishLog::TAG_SessionClose

VarnishLog::TAG_BackendOpen

VarnishLog::TAG_BackendXID

VarnishLog::TAG_BackendReuse

VarnishLog::TAG_BackendClose

VarnishLog::TAG_HttpGarbage

VarnishLog::TAG_Backend

VarnishLog::TAG_Length

VarnishLog::TAG_FetchError

VarnishLog::TAG_RxRequest

VarnishLog::TAG_RxResponse

VarnishLog::TAG_RxStatus

VarnishLog::TAG_RxURL

VarnishLog::TAG_RxProtocol

VarnishLog::TAG_RxHeader

VarnishLog::TAG_TxRequest

VarnishLog::TAG_TxResponse

VarnishLog::TAG_TxStatus

VarnishLog::TAG_TxURL

VarnishLog::TAG_TxProtocol

VarnishLog::TAG_TxHeader

VarnishLog::TAG_ObjRequest

VarnishLog::TAG_ObjResponse

VarnishLog::TAG_ObjStatus

VarnishLog::TAG_ObjURL

VarnishLog::TAG_ObjProtocol

VarnishLog::TAG_ObjHeader

VarnishLog::TAG_LostHeader

VarnishLog::TAG_TTL

VarnishLog::TAG_Fetch_Body

VarnishLog::TAG_VCL_acl

VarnishLog::TAG_VCL_call

VarnishLog::TAG_VCL_trace

VarnishLog::TAG_VCL_return

VarnishLog::TAG_VCL_error

VarnishLog::TAG_ReqStart

VarnishLog::TAG_Hit

VarnishLog::TAG_HitPass

VarnishLog::TAG_ExpBan

VarnishLog::TAG_ExpKill

VarnishLog::TAG_WorkThread

VarnishLog::TAG_ESI_xmlerror

VarnishLog::TAG_Hash

VarnishLog::TAG_Backend_health

VarnishLog::TAG_VCL_Log

VarnishLog::TAG_Gzip

VarnishLog::__construct

Varnishlog constructor

说明

public VarnishLog::__construct ([ array $args ] )

参数

args
Configuration arguments. The possible keys are:

VARNISH_CONFIG_IDENT - local varnish instance ident path

返回值

VarnishLog::getLine

Get next log line

说明

public array VarnishLog::getLine ( void )

参数

此函数没有参数。

返回值

Returns an array with the log line data.

VarnishLog::getTagName

Get the log tag string representation by its index

说明

public static string VarnishLog::getTagName ( int $index )

参数

index
Log tag index.

返回值

Returns the log tag name as string.