Cache-KyotoTycoon

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# NAME

Cache::KyotoTycoon - KyotoTycoon client library

# SYNOPSIS

    use Cache::KyotoTycoon;

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

# DESCRIPTION

KyotoTycoon.pm is [KyotoTycoon](http://fallabs.com/kyototycoon/) client library for Perl5.

**THIS MODULE IS IN ITS BETA QUALITY. THE API MAY CHANGE IN THE FUTURE**.

# ERROR HANDLING POLICY

This module throws exception if got **Server Error**.

# CONSTRUCTOR OPTIONS

- `timeout`

    Timeout value for each request in seconds.

    _Default_: 1 second

- `host`

    Host name of server machine.

    _Default_: '127.0.0.1'

- `port`

    Port number of server process. 

    _Default_: 1978 

- `db`

    DB name or id.

    _Default_: 0

# METHODS

- `$kt->db()`

    Getter/Setter of DB name/id.

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

    Create new cursor object. This method returns instance of [Cache::KyotoTycoon::Cursor](https://metacpan.org/pod/Cache::KyotoTycoon::Cursor).

- `my $res = $kt->echo($args)`

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

    $args is hashref.

    _Return_: the copy of $args.

- `$kt->report()`

    Get server report.

    _Return_: server status information in hashref.

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

    Call a procedure of the script language extension.

    _$name_: the name of the procedure to call.
    _\\%input_: (optional): arbitrary records.

    _Return_: response of the script in hashref.

- `my $info = $kt->status()`

    Get database status information.

    _Return_: database status information in hashref.

- `$kt->clear()`

    Remove all elements for the storage.

    _Return_: Not a useful value.

- `$kt->synchronize($hard:Bool, $command);`

    Synchronize database with file system.

    _$hard_: call fsync() or not.

    _$command_: call $command in synchronization state.

    _Return_: 1 if succeeded, 0 if $command returns false.

- `$kt->set($key, $value, $xt);`

    Store _$value_ to _$key_.

    _$xt_: expiration time. If $xt>0, expiration time in seconds from now. If $xt<0, the epoch time. It is never remove if missing $xt.

    _Return_: not a useful value.

- `my $ret = $kt->add($key, $value, $xt);`

    Store record. This method is not store if the _$key_ is already in the database.

    _$xt_: expiration time. If $xt>0, expiration time in seconds from now. If $xt<0, the epoch time. It is never remove if missing $xt.



( run in 1.834 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )