DBIO-MySQL-Async
Async MySQL/MariaDB storage for DBIO using EV::MariaDB.
Bypasses DBI entirely - speaks MariaDB's C client library directly for maximum performance with pipeline mode support.
Features
- Non-blocking queries - returns Futures, never blocks the event loop
- Pipeline mode - batch queries in a single network round-trip (up to 64 in-flight)
- Connection pooling - with transaction pinning
- AccessBroker support -
Schema->connect($broker)with broker-refreshed conninfo for new pool connections - Sync fallback -
->all,->firstetc. still work (blocking)
Synopsis
my $schema = MyApp::Schema->connect(
'DBIO::MySQL::Async',
{
host => 'localhost',
database => 'myapp',
user => 'myapp',
password => 'secret',
pool_size => 10,
},
);
use DBIO::AccessBroker::Static;
my $broker = DBIO::AccessBroker::Static->new(
host => 'localhost',
database => 'myapp',
user => 'myapp',
password => 'secret',
);
my $brokered = MyApp::Schema->connect($broker);
# Async
$schema->resultset('Artist')->all_async->then(sub {
my @artists = @_;
say $_->name for @artists;
});
# Pipeline
$schema->storage->pipeline(sub {
Future->needs_all(
map { $schema->resultset('Artist')->create_async({ name => $_ }) }
@names
);
});
Async
The storage class returns Future objects for all query operations, enabling fully non-blocking database access.
Pipeline
Pipeline mode batches multiple queries into a single network round-trip. Up to 64 queries can be in-flight simultaneously.
Event Loop Compatibility
EV::MariaDB uses the EV event loop. This works with:
- EV directly
- AnyEvent (uses EV as backend when available)
- IO::Async via
IO::Async::Loop::EV - Mojolicious via
Mojo::Reactor::EV
Testing
# Load tests (skip without EV::MariaDB)
prove -l t/00-load.t t/01-storage-api.t
# Integration tests (need MySQL/MariaDB + EV::MariaDB)
DBIO_TEST_MYSQL_DSN='database=testdb;host=localhost' \
DBIO_TEST_MYSQL_USER=root \
DBIO_TEST_MYSQL_PASS=secret \
prove -l t/10-integration.t t/11-access-broker-live.t
Requirements
- EV::MariaDB >= 0.03
- Future >= 0.49
- DBIO
- DBIO::MySQL
Copyright
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.