Changeset 723
- Timestamp:
- 02/25/08 07:56:06 (8 months ago)
- Files:
-
- branches/binary/api/perl/dev/bench_noreply.pl (added)
- branches/binary/api/perl/lib/Cache/Memcached.pm (modified) (9 diffs)
- branches/binary/api/perl/t/04_noreply.t (added)
- branches/binary/server/memcached.h (modified) (1 diff)
- branches/binary/website/apis.bml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/binary/api/perl/lib/Cache/Memcached.pm
r722 r723 336 336 sub _write_and_read { 337 337 my Cache::Memcached $self = shift; 338 my ($sock, $line, $check_complete , $noreply) = @_;338 my ($sock, $line, $check_complete) = @_; 339 339 my $res; 340 340 my ($ret, $offset) = (undef, 0); … … 376 376 } 377 377 if ($res == length($line)) { # all sent 378 $state = $noreply ? 2 :1;378 $state = 1; 379 379 } else { # we only succeeded in sending some of it 380 380 substr($line, 0, $res, ''); # delete the part we sent … … 411 411 return 0 unless $sock; 412 412 413 my @params;414 my $noreply = not defined wantarray;415 push @params, "noreply" if $noreply;416 417 413 $self->{'stats'}->{"delete"}++; 418 414 $key = ref $key ? $key->[1] : $key; 419 415 $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); 422 418 423 419 if ($self->{'stat_callback'}) { … … 451 447 return 0 unless $sock; 452 448 453 my @params;454 my $noreply = not defined wantarray;455 push @params, "noreply" if $noreply;456 457 449 use bytes; # return bytes from length() 458 450 … … 486 478 487 479 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); 491 483 492 484 if ($self->{'debug'} && $line) { … … 523 515 $value = 1 unless defined $value; 524 516 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); 531 519 532 520 if ($self->{'stat_callback'}) { … … 789 777 sub flush_all { 790 778 my Cache::Memcached $self = shift; 791 my ($time) = @_;792 793 $time = 0 unless defined $time;794 779 795 780 my $success = 1; 796 781 797 my @params;798 my $noreply = not defined wantarray;799 push @params, "noreply" if $noreply;800 801 782 my @hosts = @{$self->{'buckets'}}; 802 803 # Distribute the delay among the servers. For instance, if $time804 # 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 810 783 foreach my $host (@hosts) { 811 my $delay = int($time);812 $time -= $delay_step;813 my $line = "flush_all $delay @params\r\n";814 784 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); 817 787 } 818 788 … … 821 791 822 792 # returns array of lines, or () on failure. 823 # FIXME: current implementation is broken.824 793 sub run_command { 825 794 my Cache::Memcached $self = shift; … … 829 798 my $line = $cmd; 830 799 while (my $res = _write_and_read($self, $sock, $line)) { 831 # FIXME: _write_and_read() won't handle undefined $line.832 800 undef $line; 833 801 $ret .= $res; 834 # FIXME: end condition is not correct.835 802 last if $ret =~ /(?:OK|END|ERROR)\r\n$/; 836 803 } branches/binary/server/memcached.h
r722 r723 437 437 #endif /* !USE_THREADS */ 438 438 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 59 59 <li><a href="https://sourceforge.net/projects/memcacheddotnet/">https://sourceforge.net/projects/memcacheddotnet/</a></li> 60 60 <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> 61 62 </ul> 62 63
