PRIV_CALL issue in vmod

AD straightflush at gmail.com
Tue Sep 13 00:09:36 CEST 2011


Ah i see. So basically if we have an expensive operation, like a DB call (as
an example), we would have to re-do it every time we use the Vmod function
inside the VCL.  The issue i am having is i have a vmod, where i would like
to return a complex struct but i cant seem to be able to do that due to
limitations on the return types.  So i was planning on writing accessor
methods (one for each element of the struct) but for each accessor, i would
need to re-query the database to get the value which was trying to avoid.

Example:

typedef struct  _mydata {
 int val1;
 int val2;
} mydata ;

 i would love to return mydata from the vmod, but instead i need to write
vmod_get_int1, vmod_get_int2 to get at these.  The issue is to populate this
struct is "expensive".  Is there a better way around this issue ?

Cheers.



On Mon, Sep 12, 2011 at 5:48 PM, Poul-Henning Kamp <phk at phk.freebsd.dk>wrote:

> In message <
> CANZWjw5t+Q0iEa-5rN6xriuy6Kw7i8Auq-z_vGj5uBKw9_gpog at mail.gmail.com>
> , AD writes:
>
> > I am trying to use the PRIV_CALL capability of the vmods in order to
> cache
> >an expensive operation used later in the vcl itself.
>
> That is not how it works.
>
> PRIV_CALL is for caching things for the next time this call is executed.
>
> The canonical example is a caching a compiled regexp.
>
> What you need is a "PRIV_SESS" or "PRIV_REQ" variable, and I'm beating
> my head against the wall trying to find the best way to implement
> that as we're speaking...
>
>
> --
> Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
> phk at FreeBSD.ORG         | TCP/IP since RFC 956
> FreeBSD committer       | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by incompetence.
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110912/06fbdd97/attachment-0003.html>


More information about the varnish-misc mailing list