NAME
DBIO::MySQL::EV - Async MySQL/MariaDB storage for DBIO via EV::MariaDB
VERSION
version 0.900001
SYNOPSIS
# Schema setup
package MyApp::Schema;
use base 'DBIO::Schema';
__PACKAGE__->load_components(qw(MySQL MySQL::EV));
# Async is opt-in per connection
my $schema = MyApp::Schema->connect(
$dsn, $user, $pass,
{ async => 'ev' },
);
# Async queries return Futures
$schema->resultset('Artist')->all_async->then(sub {
my @artists = @_;
say $_->name for @artists;
});
# Automatic wire pipelining — issue several *_async calls without awaiting
# between them; EV::MariaDB batches them in a single round-trip.
my @futures = map {
$schema->resultset('Artist')->create_async({ name => $_ })
} @names;
Future->needs_all(@futures)->then(sub { ... });
# Sync methods still work (block the event loop)
my @all = $schema->resultset('Artist')->all;
DESCRIPTION
Async MySQL/MariaDB support for DBIO using EV::MariaDB, a non-blocking MariaDB client built on MariaDB's C client library. Bypasses DBI entirely for maximum performance.
EV::MariaDB pipelines queries automatically at the wire level (consecutive issued queries are batched, up to 64 in flight) and uses prepared statements for bound queries. There is no explicit pipeline-mode API to bracket, so DBIO::MySQL::EV::Storage declares no pipeline transport capability; throughput comes for free from issuing several *_async calls without awaiting between them.
This module is an inert marker component for async MySQL/MariaDB. Loading it via load_components('MySQL::EV') does not by itself switch the storage to async: it only tags the schema so the DBIO::MySQL::Storage MRO arm can resolve the ev mode. Async is an explicit, per-connection choice (ADR 0030); you opt in at connect time with { async => 'ev' }:
my $schema = MyApp::Schema->connect(
$dsn, $user, $pass,
{ async => 'ev' },
);
The ev mode resolves to DBIO::MySQL::EV::Storage (this distribution) and is registered by DBIO::MySQL::Storage (the sync driver); the registration is its own karr ticket and lives in the DBIO::MySQL distribution, not here. With { async = 'ev' }> on a schema that has loaded this component, the *_async methods on the resulting storage run real non-blocking queries over EV::MariaDB.
$storage->insert_async resolves with the returned-columns hashref (autoinc PK overlaid onto the supplied insert data), per ADR 0031 §3 -- MySQL has no RETURNING clause, so the EV storage assembles the hashref from LAST_INSERT_ID() on the pinned connection. select_async resolves with the raw row arrayrefs (cursor ->all shape) and select_single_async with a single row arrayref, matching the sync cursor shape. Backend Future ->then callbacks auto-wrap a plain return into a resolved Future (ADR 0031 §4), which is the native Future.pm behaviour.
EVENT LOOP COMPATIBILITY
EV::MariaDB uses the EV event loop. This works with:
SEE ALSO
DBIO::MySQL::EV::Storage, DBIO::MySQL::Storage, DBIO::Storage::Async.
ADRs 0030 and 0031 in the DBIO distribution's docs/adr/.
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.