This file is indexed.

/usr/share/doc/libkyototycoon2/example/ktrestex.pl is in kyototycoon-doc 0.9.56-1build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use strict;
use warnings;
use LWP::UserAgent;
use URI::Escape;

{
    # RESTful interface of Kyoto Tycoon
    package KyotoTycoon;

    # constructor
    sub new {
        my $self = {};
        bless $self;
        return $self;
    }

    # connect to the server
    sub open {
        my ($self, $host, $port, $timeout) = @_;
        $host = "127.0.0.1" if (!defined($host));
        $port = 1978 if (!defined($port));
        $timeout = 30 if (!defined($timeout));
        $self->{base} = "http://$host:$port/";
        $self->{ua} = LWP::UserAgent->new(keep_alive => 1);
        $self->{ua}->timeout($timeout);
        return undef;
    }

    # close the connection
    sub close {
        my ($self) = @_;
        $self->{ua} = undef;
        return undef;
    }

    # store a record
    sub set {
        my ($self, $key, $value, $xt) = @_;
        my $url = $self->{base} . URI::Escape::uri_escape($key);
        my @headers;
        if (defined($xt)) {
            $xt = time() + $xt;
            push(@headers, "X-Kt-Xt");
            push(@headers, $xt);
        }
        my $req = HTTP::Request->new(PUT => $url, \@headers, $value);
        my $res = $self->{ua}->request($req);
        my $code = $res->code();
        return $code == 201;
    }

    # remove a record
    sub remove {
        my ($self, $key) = @_;
        my $url = $self->{base} . URI::Escape::uri_escape($key);
        my $req = HTTP::Request->new(DELETE => $url);
        my $res = $self->{ua}->request($req);
        my $code = $res->code();
        return $code == 204;
    }

    # retrieve the value of a record
    sub get {
        my ($self, $key) = @_;
        my $url = $self->{base} . URI::Escape::uri_escape($key);
        my $req = HTTP::Request->new(GET => $url);
        my $res = $self->{ua}->request($req);
        my $code = $res->code();
        return undef if ($code != 200);
        return $res->content();
    }

}

# sample usage
my $kt = new KyotoTycoon;
$kt->open("localhost", 1978);
$kt->set("japan", "tokyo", 30);
printf("%s\n", $kt->get("japan"));
$kt->remove("japan");
$kt->close();