Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


   


   


   















      :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nginx memcached


  • To: nginx-ru@xxxxxxxxx
  • Subject: nginx memcached
  • From: Andrey Zloy <andrey.zloy@xxxxxxxxx>
  • Date: Sun, 25 Oct 2009 12:36:49 +0300
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=NljhvG9Hr9veUeQOY+LArhFO9D6xfDAogqdjfb97tGM=; b=dXLG3BD1ZToFUJQnI2SBk39kyl+ER97dZFL+eDzOSTznV8vJg3m4a8+tE7qOYmkFI1 wUGT46O7cJ14YyixEJG/WI0w39bhcVbMq65ywdXnLf/Agv6io/7QFQCiTlQiGOzh6Ifh SPCz+xmLUVWXMjZAxTGwT38T/ILjzkkx3+kT8=
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=gNYSbcsIGkWSUcK00mzJNIiaBX9Im9pUtpAH6eDFcESD+GiuNp1zkwbGi6gZlqibJP arOw2ikKUEAmPge9TaMUlnc77bW/PIuM78nuidBzFVdt5ic8zoWqP58c+d2/YANbpZeQ dRcPuyNg864GODlcKpwfncTzeg8x2mZKAlpNk=

, nginx' "" memcached .
Cache::Memcached.
md5 url' .

. .

?

http {
perl_set $md5_uri 'sub {
use Digest::MD5 qw(md5_base64);
my $r = shift;
my $uri=$r->uri;
my $args=$r->args;
if ($args){
$uri=$uri."?".$args;
}
return md5_base64($uri);
}';

perl_set $memcached_index '
sub {
use String::CRC32;
my $r = shift;
return (((crc32($r->variable("md5_uri")) >> 16) & 0x7fff) % 2); # 2 - - memcached
}
';

server {
listen 3666;
server_name 172.28.144.68;

location / {
set $memcached_key $md5_uri;
if ($memcached_index = 0){
memcached_pass 172.28.144.52:11211;
}
if ($memcached_index = 1){
memcached_pass 172.28.144.53:11211;
}

error_page 404 @fallback;
}
}
}



 




Copyright © Lexa Software, 1996-2009.