Welcome! Log In Create A New Profile

Advanced

Re: Setting memcache keys in eval block

Markus Jelsma
February 10, 2010 05:24AM
Hello,


Thanks for your reply. The manual indeed tells us to set it inside the block,
which i am doing. However, the first result cannot be passed to the second
eval block;

The following does not work; it sends the error message $memc_key variable is
not set:

eval $key
{
# Check if we got the token, a 160bit SHA1 hash
if ($cookie_token ~* "([A-Za-z0-9]{40})")
{
# Attempt to retrieve the token from memcache
set $memc_cmd 'get';
set $memc_key $cookie_token;

# Retrieve the token's value and store it in the local key variable
memc_pass 127.0.0.1:11211;
}
}
eval $email
{
set $memc_cmd 'get';
set $memc_key $key;
memc_pass 127.0.0.1:11211;
}

echo 'test';
echo $email;
echo_flush;

I really need two seperate gets. Nesting the second eval in the first is also
not allowed because then we have a duplicate memc_pass which it complains
about.

For the moment i `solved` this issue by adding a second location which the
first eval proxies to, this does work but shows up as a second HTTP request in
the logs; this feels a bit slow and i really would like to handle this subject
within one location directive.

To summarize the problem; using a variable set by eval in a subsequent eval
block does not work.

Some advice is much appreciated :)



Cheers,





The eval module's handler runs before the ngx_rewrite module. So make
sure you always "set" variables inside the eval block. The "set"
directives outside the eval block does not work because they run after
the "eval" block and hence the memcached handler complete.

IIRC, this was mentioned in the ngx_eval module's documentation.


Markus Jelsma - Technisch Architect - Buyways BV
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Setting memcache keys in eval block

Markus Jelsma February 08, 2010 07:48AM

Re: Setting memcache keys in eval block

agentzh February 08, 2010 09:44PM

Re: Setting memcache keys in eval block

Markus Jelsma February 10, 2010 05:24AM

Re: Setting memcache keys in eval block

agentzh February 10, 2010 05:40AM

Re: Setting memcache keys in eval block

Markus Jelsma February 10, 2010 05:52AM

Re: Setting memcache keys in eval block

Eugaia February 10, 2010 11:10PM

Re: Setting memcache keys in eval block

agentzh February 11, 2010 10:30PM

Re: Setting memcache keys in eval block

agentzh February 11, 2010 04:38AM

Re: Setting memcache keys in eval block

agentzh February 11, 2010 04:44AM

Re: Setting memcache keys in eval block

agentzh February 11, 2010 10:28PM

Re: Setting memcache keys in eval block

Markus Jelsma February 12, 2010 05:00AM

Re: Setting memcache keys in eval block

agentzh February 13, 2010 05:26AM

Re: Setting memcache keys in eval block

Valery Kholodkov February 14, 2010 10:36AM

Re: Setting memcache keys in eval block

Markus Jelsma February 14, 2010 03:04PM

Re: Setting memcache keys in eval block

Markus Jelsma February 15, 2010 05:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready