FalkorDB Perl Module

A clean, object-oriented Perl client library for FalkorDB (a low-latency graph database built on Redis). It wraps Cypher query execution, handles type serialization for query parameterization, and parses responses into structured Node, Edge, and Path objects.

Features

File Structure

Synopsis

use FalkorDB;
use JSON::PP; # For boolean wrappers

# 1. Connect
my $db = FalkorDB->new(
    host => 'falkordb',
    port => 6379,
);

# 2. Select Graph
my $graph = $db->select_graph('SocialNetwork');

# 3. Create Nodes with Parameters
$graph->query(
    "CREATE (:person {name: \$name, age: \$age, active: \$active, hobbies: \$hobbies})",
    {
        name   => "Bob O'Connor",
        age    => 28,
        active => JSON::PP::true,
        hobbies => ['hiking', 'cooking']
    }
);

# 4. Fetch Results
my $res = $graph->query(
    "MATCH (p:person) WHERE p.age = \$age RETURN p.name, p.active, p.hobbies",
    { age => 28 }
);

# Iterate as arrays
while (my $row = $res->next_row()) {
    my ($name, $active, $hobbies) = @$row;
    print "$name is active? $active, hobbies: @$hobbies\n";
}

# Or iterate as hashes
$res->reset_iterator();
while (my $hash = $res->next_hash()) {
    print "Found: ", $hash->{'p.name'}, "\n";
}

Running Tests

Ensure a FalkorDB instance is accessible at falkordb:6379, then run:

perl Makefile.PL
make test

License

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.