有人可以解释 varnish vmod 在不同情况下使用以下私有指针 PRIV_CALL、PRIV_TASK、PRIV_TOP、PRIV_VCL 吗? [英] Can someone explain varnish vmod use following private pointer in different cases PRIV_CALL, PRIV_TASK,PRIV_TOP,PRIV_VCL?

查看:16
本文介绍了有人可以解释 varnish vmod 在不同情况下使用以下私有指针 PRIV_CALL、PRIV_TASK、PRIV_TOP、PRIV_VCL 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望为 varnish 在 vmod 中接收的主机名维护一个本地状态.PRIV_CALL、PRIV_TASK、PRIV_TOP、PRIV_VCL指针使用哪个,哪个场景?这个是为了理解.

解决方案

我认为阅读 vmod 的文档可能会有所帮助:https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/vmod.rst来自文档:

  • PRIV_CALL每次调用"私有指针可用于缓存/存储与特定调用或其参数相关的状态,例如特定于 regsub() 语句的已编译正则表达式或仅缓存最近的输出一些昂贵的操作.这些私有指针在加载的 VCL 期间一直存在.

  • PRIV_TASK每个任务"私有指针对于适用于特定请求或后端请求的调用的状态很有用.例如,这可能是特定于客户端的解析 cookie 的结果.请注意,客户端和后端的 PRIV_TASK 上下文是分开的,因此在 vcl_backend_* 中使用将产生与客户端使用的私有指针不同的私有指针.这些私有指针仅在其任务期间有效.

  • PRIV_TOP每个顶级请求"私有指针在一个请求及其所有 ESI 包含的持续时间内有效.它们仅为客户端定义.当从后端 VCL subs 使用时,将传递一个 NULL 指针.这些私有指针仅在其顶级请求期间有效

  • PRIV_VCL "per vcl" 私有指针对于适用于该 VCL 中所有调用的全局状态很有用,例如确定正则表达式在该 vmod 或类似情况下是否区分大小写的标志.PRIV_VCL 对象与传递给 VMOD 的事件函数的对象相同.这个私有指针在加载的 VCL 期间一直存在.

我可能会说,如果您希望在客户端跟踪主机,那么 priv_task 就是您要寻找的.

I am looking to maintain a local state for host name that varnish receive in the vmod. which of the PRIV_CALL, PRIV_TASK,PRIV_TOP,PRIV_VCL pointers to use and which scenario?this is for the understanding.

解决方案

I think it could be of help to read the docs for the vmod: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/vmod.rst From the docs:

  • PRIV_CALL "per call" private pointers are useful to cache/store state relative to the specific call or its arguments, for instance a compiled regular expression specific to a regsub() statement or simply caching the most recent output of some expensive operation. These private pointers live for the duration of the loaded VCL.

  • PRIV_TASK "per task" private pointers are useful for state that applies to calls for either a specific request or a backend request. For instance this can be the result of a parsed cookie specific to a client. Note that PRIV_TASK contexts are separate for the client side and the backend side, so use in vcl_backend_* will yield a different private pointer from the one used on the client side. These private pointers live only for the duration of their task.

  • PRIV_TOP "per top-request" private pointers live for the duration of one request and all its ESI-includes. They are only defined for the client side. When used from backend VCL subs, a NULL pointer will be passed. These private pointers live only for the duration of their top level request

  • PRIV_VCL "per vcl" private pointers are useful for such global state that applies to all calls in this VCL, for instance flags that determine if regular expressions are case-sensitive in this vmod or similar. The PRIV_VCL object is the same object that is passed to the VMOD's event function. This private pointer lives for the duration of the loaded VCL.

I'd probably say if you wish to keep track of the Host in the client side, then priv_task is what you are looking for.

这篇关于有人可以解释 varnish vmod 在不同情况下使用以下私有指针 PRIV_CALL、PRIV_TASK、PRIV_TOP、PRIV_VCL 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆