Changeset 723

Show
Ignore:
Timestamp:
02/25/08 07:56:06 (8 months ago)
Author:
dsallings
Message:

Merge commit 'trunk' into lbinary as of r716

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/binary/api/perl/lib/Cache/Memcached.pm

    r722 r723  
    336336sub _write_and_read { 
    337337    my Cache::Memcached $self = shift; 
    338     my ($sock, $line, $check_complete, $noreply) = @_; 
     338    my ($sock, $line, $check_complete) = @_; 
    339339    my $res; 
    340340    my ($ret, $offset) = (undef, 0); 
     
    376376            } 
    377377            if ($res == length($line)) { # all sent 
    378                 $state = $noreply ? 2 : 1; 
     378                $state = 1; 
    379379            } else { # we only succeeded in sending some of it 
    380380                substr($line, 0, $res, ''); # delete the part we sent 
     
    411411    return 0 unless $sock; 
    412412 
    413     my @params; 
    414     my $noreply = not defined wantarray; 
    415     push @params, "noreply" if $noreply; 
    416  
    417413    $self->{'stats'}->{"delete"}++; 
    418414    $key = ref $key ? $key->[1] : $key; 
    419415    $time = $time ? " $time" : ""; 
    420     my $cmd = "delete $self->{namespace}$key$time @params\r\n"; 
    421     my $res = _write_and_read($self, $sock, $cmd, undef, $noreply); 
     416    my $cmd = "delete $self->{namespace}$key$time\r\n"; 
     417    my $res = _write_and_read($self, $sock, $cmd); 
    422418 
    423419    if ($self->{'stat_callback'}) { 
     
    451447    return 0 unless $sock; 
    452448 
    453     my @params; 
    454     my $noreply = not defined wantarray; 
    455     push @params, "noreply" if $noreply; 
    456  
    457449    use bytes; # return bytes from length() 
    458450 
     
    486478 
    487479    local $SIG{'PIPE'} = "IGNORE" unless $FLAG_NOSIGNAL; 
    488     my $line = "$cmdname $self->{namespace}$key $flags $exptime $len @params\r\n$val\r\n"; 
    489  
    490     my $res = _write_and_read($self, $sock, $line, undef, $noreply); 
     480    my $line = "$cmdname $self->{namespace}$key $flags $exptime $len\r\n$val\r\n"; 
     481 
     482    my $res = _write_and_read($self, $sock, $line); 
    491483 
    492484    if ($self->{'debug'} && $line) { 
     
    523515    $value = 1 unless defined $value; 
    524516 
    525     my @params; 
    526     my $noreply = not defined wantarray; 
    527     push @params, "noreply" if $noreply; 
    528  
    529     my $line = "$cmdname $self->{namespace}$key $value @params\r\n"; 
    530     my $res = _write_and_read($self, $sock, $line, undef, $noreply); 
     517    my $line = "$cmdname $self->{namespace}$key $value\r\n"; 
     518    my $res = _write_and_read($self, $sock, $line); 
    531519 
    532520    if ($self->{'stat_callback'}) { 
     
    789777sub flush_all { 
    790778    my Cache::Memcached $self = shift; 
    791     my ($time) = @_; 
    792  
    793     $time = 0 unless defined $time; 
    794779 
    795780    my $success = 1; 
    796781 
    797     my @params; 
    798     my $noreply = not defined wantarray; 
    799     push @params, "noreply" if $noreply; 
    800  
    801782    my @hosts = @{$self->{'buckets'}}; 
    802  
    803     # Distribute the delay among the servers.  For instance, if $time 
    804     # is 30 seconds, and we have 3 servers, they will get 30, 15, 0. 
    805     my $delay_step = 0; 
    806     if (@hosts > 1) { 
    807         $delay_step = $time / (@hosts - 1); 
    808     } 
    809  
    810783    foreach my $host (@hosts) { 
    811         my $delay = int($time); 
    812         $time -= $delay_step; 
    813         my $line = "flush_all $delay @params\r\n"; 
    814784        my $sock = $self->sock_to_host($host); 
    815         my $res = _write_and_read($self, $sock, $line, undef, $noreply); 
    816         $success = 0 unless ($noreply or $res eq "OK\r\n"); 
     785        my @res = $self->run_command($sock, "flush_all\r\n"); 
     786        $success = 0 unless (@res); 
    817787    } 
    818788 
     
    821791 
    822792# returns array of lines, or () on failure. 
    823 # FIXME: current implementation is broken. 
    824793sub run_command { 
    825794    my Cache::Memcached $self = shift; 
     
    829798    my $line = $cmd; 
    830799    while (my $res = _write_and_read($self, $sock, $line)) { 
    831         # FIXME: _write_and_read() won't handle undefined $line. 
    832800        undef $line; 
    833801        $ret .= $res; 
    834         # FIXME: end condition is not correct. 
    835802        last if $ret =~ /(?:OK|END|ERROR)\r\n$/; 
    836803    } 
  • branches/binary/server/memcached.h

    r722 r723  
    437437#endif /* !USE_THREADS */ 
    438438 
    439  
     439/* If supported, give compiler hints for branch prediction. */ 
     440#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) 
     441#define __builtin_expect(x, expected_value) (x) 
     442#endif 
     443 
     444#define likely(x)       __builtin_expect((x),1) 
     445#define unlikely(x)     __builtin_expect((x),0) 
  • branches/binary/website/apis.bml

    r717 r723  
    5959<li><a href="https://sourceforge.net/projects/memcacheddotnet/">https://sourceforge.net/projects/memcacheddotnet/</a></li> 
    6060<li><a href="http://www.codeplex.com/EnyimMemcached/">http://www.codeplex.com/EnyimMemcached/</a> - Client developed in .NET 2.0 keeping performance and extensibility in mind. (Supports consistent hashing.)</li> 
     61<li><a href="http://code.google.com/p/beitmemcached/">http://code.google.com/p/beitmemcached/</a> - Client developed by BeIT with many new features.</li> 
    6162</ul> 
    6263