Cache-KyotoTycoon

 view release on metacpan or  search on metacpan

lib/Cache/KyotoTycoon.pm  view on Meta::CPAN

        if ($k =~ /^_(.+)$/) {
            $ret{$1} = $v;
        }
    }
    die "fatal error" unless keys(%ret) == $body->{num};
    return wantarray ? %ret : \%ret;
}

sub match_similar {
    my ($self, $origin, $range, $utf8, $max) = @_;
    my %args = (DB => $self->db, origin => $origin);
    $args{range} = $max if defined $range;
    $args{utf}   = 1    if $utf8;
    $args{max}   = $max if defined $max;
    my ($code, $body, $msg) = $self->{client}->call('match_similar', \%args);
    Carp::croak _errmsg($code, $msg) unless $code eq '200';
    my %ret;

    while (my ($k, $v) = each %$body) {
        if ($k =~ /^_(.+)$/) {
            $ret{$1} = $v;
        }
    }
    die "fatal error" unless keys(%ret) == $body->{num};
    return wantarray ? %ret : \%ret;
}

1;
__END__

=encoding utf8

=head1 NAME

Cache::KyotoTycoon - KyotoTycoon client library

=head1 SYNOPSIS

    use Cache::KyotoTycoon;

    my $kt = Cache::KyotoTycoon->new(host => '127.0.0.1', port => 1978);
    $kt->set('foo' => bar');
    $kt->get('foo'); # => 'bar'

=head1 DESCRIPTION

KyotoTycoon.pm is L<KyotoTycoon|http://fallabs.com/kyototycoon/> client library for Perl5.

B<THIS MODULE IS IN ITS BETA QUALITY. THE API MAY CHANGE IN THE FUTURE>.

=head1 ERROR HANDLING POLICY

This module throws exception if got B<Server Error>.

=head1 CONSTRUCTOR OPTIONS

=over 4

=item C<< timeout >>

Timeout value for each request in seconds.

I<Default>: 1 second

=item C<< host >>

Host name of server machine.

I<Default>: '127.0.0.1'

=item C<< port >>

Port number of server process. 

I<Default>: 1978 

=item C<< db >>

DB name or id.

I<Default>: 0

=back

=head1 METHODS

=over 4

=item C<< $kt->db() >>

Getter/Setter of DB name/id.

=item C<< my $cursor: Cache::KyotoTycoon::Cursor = $kt->make_cursor($cursor_number: Int); >>

Create new cursor object. This method returns instance of L<Cache::KyotoTycoon::Cursor>.

=item C<< my $res = $kt->echo($args) >>

The server returns $args. This method is useful for testing server.

$args is hashref.

I<Return>: the copy of $args.

=item C<< $kt->report() >>

Get server report.

I<Return>: server status information in hashref.

=item C<< my $output = $kt->play_script($name[, \%input]); >>

Call a procedure of the script language extension.

I<$name>: the name of the procedure to call.
I<\%input>: (optional): arbitrary records.

I<Return>: response of the script in hashref.

=item C<< my $info = $kt->status() >>



( run in 0.521 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )