Book/varnish-Phpdoc专题
Varnish
目录
- 简介
- 安装/配置
- 预定义常量
- 范例
- VarnishAdmin — The VarnishAdmin class
- VarnishAdmin::auth — Authenticate on a varnish instance
- VarnishAdmin::ban — Ban URLs using a VCL expression
- VarnishAdmin::banUrl — Ban an URL using a VCL expression
- VarnishAdmin::clearPanic — Clear varnish instance panic messages
- VarnishAdmin::connect — Connect to a varnish instance administration interface
- VarnishAdmin::__construct — VarnishAdmin constructor
- VarnishAdmin::disconnect — Disconnect from a varnish instance administration interface
- VarnishAdmin::getPanic — Get the last panic message on a varnish instance
- VarnishAdmin::getParams — Fetch current varnish instance configuration parameters
- VarnishAdmin::isRunning — Check if the varnish slave process is currently running
- VarnishAdmin::setCompat — Set the class compat configuration param
- VarnishAdmin::setHost — Set the class host configuration param
- VarnishAdmin::setIdent — Set the class ident configuration param
- VarnishAdmin::setParam — Set configuration param on the current varnish instance
- VarnishAdmin::setPort — Set the class port configuration param
- VarnishAdmin::setSecret — Set the class secret configuration param
- VarnishAdmin::setTimeout — Set the class timeout configuration param
- VarnishAdmin::start — Start varnish worker process
- VarnishAdmin::stop — Stop varnish worker process
- VarnishStat — The VarnishStat class
- VarnishStat::__construct — VarnishStat constructor
- VarnishStat::getSnapshot — Get the current varnish instance statistics snapshot
- VarnishLog — The VarnishLog class
- VarnishLog::__construct — Varnishlog constructor
- VarnishLog::getLine — Get next log line
- VarnishLog::getTagName — Get the log tag string representation by its index
简介
类摘要
VarnishAdmin
class VarnishAdmin {
/* 方法 */
public bool auth ( <span class="methodparam">void )
public int <span
class="methodname">ban ( <span
class="type">string $vcl_regex
)
public int <span
class="methodname">banUrl ( <span
class="type">string $vcl_regex
)
public int <span class="methodname">clearPanic ( <span class="methodparam">void )
public bool connect ( <span class="methodparam">void )
public <span
class="methodname">__construct ([ <span
class="methodparam">array $args
] )
public bool disconnect ( <span class="methodparam">void )
public string getPanic ( <span class="methodparam">void )
public array getParams ( <span class="methodparam">void )
public bool isRunning ( <span class="methodparam">void )
public void
setCompat ( <span
class="methodparam">int $compat
)
public void
setHost ( <span
class="methodparam">string $host
)
public void
setIdent ( <span
class="methodparam">string $ident
)
public int <span
class="methodname">setParam ( <span
class="type">string $name
, <span
class="methodparam"><span
class="type">stringint
$value
)
public void
setPort ( <span
class="methodparam">int $port
)
public void
setSecret ( <span
class="methodparam">string $secret
)
public void
setTimeout ( <span
class="methodparam">int $timeout
)
public int <span class="methodname">start ( void )
public int <span class="methodname">stop ( void )
}
VarnishAdmin::auth
Authenticate on a varnish instance
说明
public bool VarnishAdmin::auth ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
成功时返回 true
, 或者在失败时返回 false
。
VarnishAdmin::ban
Ban URLs using a VCL expression
说明
public int <span
class="methodname">VarnishAdmin::ban ( <span
class="methodparam">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 <span
class="methodname">VarnishAdmin::banUrl ( <span
class="methodparam">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 <span class="methodname">VarnishAdmin::clearPanic ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Returns the varnish command status.
VarnishAdmin::connect
Connect to a varnish instance administration interface
说明
public bool VarnishAdmin::connect ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
成功时返回 true
, 或者在失败时返回 false
。
VarnishAdmin::__construct
VarnishAdmin constructor
说明
public <span
class="methodname">VarnishAdmin::__construct ([ <span
class="methodparam">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 ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
成功时返回 true
, 或者在失败时返回 false
。
VarnishAdmin::getPanic
Get the last panic message on a varnish instance
说明
public string VarnishAdmin::getPanic ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Returns the last panic message on the current varnish instance.
VarnishAdmin::getParams
Fetch current varnish instance configuration parameters
说明
public array VarnishAdmin::getParams ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Returns an array with the varnish configuration parameters.
VarnishAdmin::isRunning
Check if the varnish slave process is currently running
说明
public bool VarnishAdmin::isRunning ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
成功时返回 true
, 或者在失败时返回 false
。
VarnishAdmin::setCompat
Set the class compat configuration param
说明
public void
VarnishAdmin::setCompat ( <span
class="methodparam">int $compat
)
参数
compat
Varnish compatibility option.
返回值
VarnishAdmin::setHost
Set the class host configuration param
说明
public void
VarnishAdmin::setHost ( <span
class="methodparam">string $host
)
参数
host
Connection host configuration parameter.
返回值
VarnishAdmin::setIdent
Set the class ident configuration param
说明
public void
VarnishAdmin::setIdent ( <span
class="methodparam">string $ident
)
参数
ident
Connection ident configuration parameter.
返回值
VarnishAdmin::setParam
Set configuration param on the current varnish instance
说明
public int <span
class="methodname">VarnishAdmin::setParam ( <span
class="methodparam">string $name
,
<span
class="type">stringint
$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 ( <span
class="methodparam">int $port
)
参数
port
Connection port configuration parameter.
返回值
VarnishAdmin::setSecret
Set the class secret configuration param
说明
public void
VarnishAdmin::setSecret ( <span
class="methodparam">string $secret
)
参数
secret
Connection secret configuration parameter.
返回值
VarnishAdmin::setTimeout
Set the class timeout configuration param
说明
public void
VarnishAdmin::setTimeout ( <span
class="methodparam">int $timeout
)
参数
timeout
Connection timeout configuration parameter.
返回值
VarnishAdmin::start
Start varnish worker process
说明
public int <span class="methodname">VarnishAdmin::start ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Returns the varnish command status.
VarnishAdmin::stop
Stop varnish worker process
说明
public int <span class="methodname">VarnishAdmin::stop ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Returns the varnish command status.
简介
类摘要
VarnishStat
class VarnishStat {
/* 方法 */
public <span
class="methodname">__construct ([ <span
class="methodparam">array $args
] )
public array getSnapshot ( <span class="methodparam">void )
}
VarnishStat::__construct
VarnishStat constructor
说明
public <span
class="methodname">VarnishStat::__construct ([ <span
class="methodparam">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 ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Array with the varnish statistic snapshot. The array keys are identical to that in the varnishstat tool.
简介
类摘要
VarnishLog
class VarnishLog {
/* Constants */
const int
VarnishLog::TAG_Debug
= 0 ;
const int
VarnishLog::TAG_Error
= 1 ;
const int
VarnishLog::TAG_CLI
= 2 ;
const int
VarnishLog::TAG_StatSess
= 3 ;
const int
VarnishLog::TAG_ReqEnd
= 4 ;
const int
VarnishLog::TAG_SessionOpen
= 5 ;
const int
VarnishLog::TAG_SessionClose
= 6 ;
const int
VarnishLog::TAG_BackendOpen
= 7 ;
const int
VarnishLog::TAG_BackendXID
= 8 ;
const int
VarnishLog::TAG_BackendReuse
= 9 ;
const int
VarnishLog::TAG_BackendClose
= 10 ;
const int
VarnishLog::TAG_HttpGarbage
= 11 ;
const int
VarnishLog::TAG_Backend
= 12 ;
const int
VarnishLog::TAG_Length
= 13 ;
const int
VarnishLog::TAG_FetchError
= 14 ;
const int
VarnishLog::TAG_RxRequest
= 15 ;
const int
VarnishLog::TAG_RxResponse
= 16 ;
const int
VarnishLog::TAG_RxStatus
= 17 ;
const int
VarnishLog::TAG_RxURL
= 18 ;
const int
VarnishLog::TAG_RxProtocol
= 19 ;
const int
VarnishLog::TAG_RxHeader
= 20 ;
const int
VarnishLog::TAG_TxRequest
= 21 ;
const int
VarnishLog::TAG_TxResponse
= 22 ;
const int
VarnishLog::TAG_TxStatus
= 23 ;
const int
VarnishLog::TAG_TxURL
= 24 ;
const int
VarnishLog::TAG_TxProtocol
= 25 ;
const int
VarnishLog::TAG_TxHeader
= 26 ;
const int
VarnishLog::TAG_ObjRequest
= 27 ;
const int
VarnishLog::TAG_ObjResponse
= 28 ;
const int
VarnishLog::TAG_ObjStatus
= 29 ;
const int
VarnishLog::TAG_ObjURL
= 30 ;
const int
VarnishLog::TAG_ObjProtocol
= 31 ;
const int
VarnishLog::TAG_ObjHeader
= 32 ;
const int
VarnishLog::TAG_LostHeader
= 33 ;
const int
VarnishLog::TAG_TTL
= 34 ;
const int
VarnishLog::TAG_Fetch_Body
= 35 ;
const int
VarnishLog::TAG_VCL_acl
= 36 ;
const int
VarnishLog::TAG_VCL_call
= 37 ;
const int
VarnishLog::TAG_VCL_trace
= 38 ;
const int
VarnishLog::TAG_VCL_return
= 39 ;
const int
VarnishLog::TAG_VCL_error
= 40 ;
const int
VarnishLog::TAG_ReqStart
= 41 ;
const int
VarnishLog::TAG_Hit
= 42 ;
const int
VarnishLog::TAG_HitPass
= 43 ;
const int
VarnishLog::TAG_ExpBan
= 44 ;
const int
VarnishLog::TAG_ExpKill
= 45 ;
const int
VarnishLog::TAG_WorkThread
= 46 ;
const int
VarnishLog::TAG_ESI_xmlerror
= 47 ;
const int
VarnishLog::TAG_Hash
= 48 ;
const int
VarnishLog::TAG_Backend_health
= 49
;
const int
VarnishLog::TAG_VCL_Log
= 50 ;
const int
VarnishLog::TAG_Gzip
= 51 ;
/* 方法 */
public <span
class="methodname">__construct ([ <span
class="methodparam">array $args
] )
public array getLine ( <span class="methodparam">void )
public <span
class="modifier">static string <span
class="methodname">getTagName ( <span
class="type">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 <span
class="methodname">VarnishLog::__construct ([ <span
class="methodparam">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 ( <span class="methodparam">void )
参数
此函数没有参数。
返回值
Returns an array with the log line data.
VarnishLog::getTagName
Get the log tag string representation by its index
说明
public <span
class="modifier">static string <span
class="methodname">VarnishLog::getTagName ( <span
class="methodparam">int $index
)
参数
index
Log tag index.
返回值
Returns the log tag name as string.