Cache-KyotoTycoon
view release on metacpan or search on metacpan
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.
lib/Cache/KyotoTycoon.pm view on Meta::CPAN
}
sub clear {
my ($self, ) = @_;
my %args = (DB => $self->db);
my ($code, $body, $msg) = $self->{client}->call('clear', \%args);
Carp::croak _errmsg($code, $msg) unless $code eq 200;
return;
}
sub synchronize {
my ($self, $hard, $command) = @_;
my %args = (DB => $self->db);
$args{hard} = $hard if $hard;
$args{command} = $command if defined $command;
my ($code, $body, $msg) = $self->{client}->call('synchronize', \%args);
return 1 if $code eq 200;
return 0 if $code eq 450;
Carp::croak _errmsg($code, $msg);
}
sub set {
my ($self, $key, $value, $xt) = @_;
my %args = (DB => $self->db, key => $key, value => $value);
$args{xt} = $xt if defined $xt;
my ($code, $body, $msg) = $self->{client}->call('set', \%args);
lib/Cache/KyotoTycoon.pm view on Meta::CPAN
Get database status information.
I<Return>: database status information in hashref.
=item C<< $kt->clear() >>
Remove all elements for the storage.
I<Return>: Not a useful value.
=item C<< $kt->synchronize($hard:Bool, $command); >>
Synchronize database with file system.
I<$hard>: call fsync() or not.
I<$command>: call $command in synchronization state.
I<Return>: 1 if succeeded, 0 if $command returns false.
=item C<< $kt->set($key, $value, $xt); >>
Store I<$value> to I<$key>.
I<$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.
I<Return>: not a useful value.
t/live/002_misc.t view on Meta::CPAN
my $got = $kt->report();
note Dumper($got);
ok(keys(%$got) > 0);
};
subtest 'status' => sub {
my $got = $kt->status();
note Dumper($got);
ok exists($got->{count});
ok exists($got->{size});
};
subtest 'synchronize' => sub {
my $got = $kt->synchronize();
is($got, 1);
};
subtest 'vacuum' => sub {
$kt->vacuum();
$kt->vacuum(1);
ok 1;
};
subtest 'clear' => sub {
$kt->clear();
ok 1;
( run in 0.379 second using v1.01-cache-2.11-cpan-05444aca049 )