| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FalkorDB; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
486461
|
use strict; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
189
|
|
|
4
|
6
|
|
|
6
|
|
24
|
use warnings; |
|
|
6
|
|
|
|
|
28
|
|
|
|
6
|
|
|
|
|
213
|
|
|
5
|
6
|
|
|
6
|
|
2644
|
use Redis::Fast; |
|
|
6
|
|
|
|
|
649251
|
|
|
|
6
|
|
|
|
|
197
|
|
|
6
|
6
|
|
|
6
|
|
38
|
use Carp qw(croak); |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
250
|
|
|
7
|
6
|
|
|
6
|
|
2315
|
use FalkorDB::Graph; |
|
|
6
|
|
|
|
|
51
|
|
|
|
6
|
|
|
|
|
2206
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
0
|
|
|
0
|
1
|
|
my ( $class, %args ) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $redis; |
|
15
|
0
|
0
|
|
|
|
|
if ( $args{redis} ) { |
|
16
|
0
|
|
|
|
|
|
$redis = $args{redis}; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
else { |
|
19
|
0
|
|
0
|
|
|
|
my $host = $args{host} // 'falkordb'; |
|
20
|
0
|
|
0
|
|
|
|
my $port = $args{port} // 6379; |
|
21
|
0
|
|
|
|
|
|
my $server = "$host:$port"; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my %redis_args = ( server => $server, ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Only add password if it is defined and not empty |
|
26
|
0
|
0
|
0
|
|
|
|
if ( defined $args{password} && $args{password} ne '' ) { |
|
27
|
0
|
|
|
|
|
|
$redis_args{password} = $args{password}; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$redis = Redis::Fast->new(%redis_args); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# If username is provided, we can attempt AUTH (RESP3 uses AUTH username password) |
|
33
|
|
|
|
|
|
|
# But for empty username/password as requested, we don't need to authenticate. |
|
34
|
0
|
0
|
0
|
|
|
|
if ( defined $args{username} |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
35
|
|
|
|
|
|
|
&& $args{username} ne '' |
|
36
|
|
|
|
|
|
|
&& defined $args{password} |
|
37
|
|
|
|
|
|
|
&& $args{password} ne '' ) |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
|
|
|
$redis->auth( $args{username}, $args{password} ); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $self = { redis => $redis, }; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return bless $self, $class; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub redis { |
|
49
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
50
|
0
|
|
|
|
|
|
return $self->{redis}; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub select_graph { |
|
54
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
|
55
|
0
|
|
|
|
|
|
return FalkorDB::Graph->new( $self, $name ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub graph { |
|
59
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
|
60
|
0
|
|
|
|
|
|
return $self->select_graph($name); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub delete_graph { |
|
64
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
|
65
|
0
|
|
|
|
|
|
my ( $res, $error ) = $self->{redis}->__std_cmd( "GRAPH.DELETE", $name ); |
|
66
|
0
|
0
|
|
|
|
|
if ( defined $error ) { |
|
67
|
0
|
|
|
|
|
|
croak("[GRAPH.DELETE] $error"); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
|
0
|
|
|
|
return defined $res && $res eq 'OK'; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub list_graphs { |
|
73
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
74
|
0
|
|
|
|
|
|
my ( $res, $error ) = $self->{redis}->__std_cmd("GRAPH.LIST"); |
|
75
|
0
|
0
|
|
|
|
|
if ( defined $error ) { |
|
76
|
0
|
|
|
|
|
|
croak("[GRAPH.LIST] $error"); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
0
|
0
|
|
|
|
|
return ref $res eq 'ARRAY' ? $res : []; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
__END__ |