Changeset 11305

Show
Ignore:
Timestamp:
05/09/08 23:51:30 (5 years ago)
Author:
daisuke
Message:

fix namespace support

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Cache-Memcached-libmemcached/trunk/lib/Cache/Memcached/libmemcached.pm

    r9665 r11305  
    3737    foreach my $method qw(set add replace prepend append cas) { 
    3838        eval <<"        EOSUB"; 
    39             sub $method { shift->memcached_$method(\@_[0, 1], int(\$_[2] || 0)) } 
     39            sub $method {  
     40                my \$self = shift; 
     41                \$self->memcached_$method(\$self->{namespace} . \$_[0], \$_[1], int(\$_[2] || 0)) 
     42            } 
    4043        EOSUB 
    4144        die if $@; 
     
    7679    $self->set_hashing_algorithm( $args->{hashing_algorithm} ) if exists $args->{hashing_algorithm}; 
    7780    $self->set_distribution_method( $args->{distribution_method} ) if exists $args->{distribution_method}; 
     81 
     82    $self->{namespace} = $args->{namespace} || ''; 
    7883 
    7984    return $self; 
     
    101106        $self->memcached_server_add_unix_socket( $server ); 
    102107    } 
     108} 
     109 
     110sub get 
     111{ 
     112    my $self = shift; 
     113    my $key  = shift; 
     114    $self->SUPER::get($self->{namespace} . $key, @_); 
    103115} 
    104116