NAME

DBIO::MySQL::Async::Storage - Async MySQL/MariaDB storage driver using EV::MariaDB

VERSION

version 0.900000

DESCRIPTION

Implements DBIO::Storage::Async using EV::MariaDB — a non-blocking MariaDB/MySQL client that speaks the MariaDB C client library directly. No DBI, no DBD::MySQL, just raw MariaDB performance.

Features:

  • Pipeline mode — batch queries in a single network round-trip

  • Prepared statement caching

  • Connection pooling with transaction pinning

METHODS

future_class

Returns 'Future' — uses Future.pm from CPAN.

connect_info

$storage->connect_info([ \%conninfo, \%opts ]);

Set connection parameters. %conninfo is passed directly to EV::MariaDB as connection parameters (host, user, password, database, etc.).

pool

Returns the DBIO::MySQL::Async::Pool connection pool. Created lazily on first access.

sql_maker

Returns the DBIO::MySQL::SQLMaker instance, configured for MySQL (backtick quoting, MySQL LIMIT offset, rows pagination).

select_async

my $future = $storage->select_async($source, $select, $where, $attrs);

Execute a SELECT query asynchronously. Returns a Future that resolves with the result rows (arrayrefs).

select_single_async

Like "select_async" but returns only the first row.

insert_async

my $future = $storage->insert_async($source, \%vals);

update_async

my $future = $storage->update_async($source, \%vals, \%where);

delete_async

my $future = $storage->delete_async($source, \%where);

txn_do_async

my $future = $storage->txn_do_async(sub {
    my ($storage) = @_;
    # All queries in here use the same connection
    $storage->insert_async(...)->then(sub { ... });
});

Acquires a connection from the pool, issues BEGIN, executes the coderef, and issues COMMIT on success or ROLLBACK on Future failure.

pipeline

my $future = $storage->pipeline(sub {
    my ($storage) = @_;
    my @futures;
    push @futures, $storage->insert_async('artist', { name => $_ })
        for @names;
    return Future->needs_all(@futures);
});

Execute multiple queries in pipeline mode. All queries are batched and sent in a single network round-trip for maximum throughput. EV::MariaDB supports up to 64 pipelined queries.

in_txn

Returns true when invoked on a DBIO::MySQL::Async::TransactionContext (the coderef inside "txn_do_async"), false on the storage itself. Used by sub-queries that need to know whether the current connection is pinned.

last_insert_id

my $id = $storage->last_insert_id;

Returns the auto-increment value from the last INSERT performed on this storage instance. Valid after insert_async or insert succeeds.

AUTHOR

DBIO Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors

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