KiokuD...le::TXN(3pm)
π KiokuDB::Backend::Role::TXN π
okay bestie, listen. this is the KiokuDB::Backend::Role::TXN page from the Perl user-contributed docs, and it's giving backend level transaction support. we're doing version 0.57 today. no cap, this one's a role, so buckle up π
β¨ VERSION β¨
version 0.57 β that's the one, that's the girl π
πΈ SYNOPSIS πΈ
so you wanna make your own backend and have it do transactions? you literally just with the role, like this:
package MyBackend;
use Moose;
with qw(
KiokuDB::Backend
KiokuDB::Backend::Role::TXN
);
sub txn_begin { ... }
sub txn_commit { ... }
sub txn_rollback { ... }
and then you gotta actually write those three subs, because the role is not gonna do them for you, bestie. it's just the vibe contract. β¨
π¦ DESCRIPTION π¦
the way this API is inspired by standard database transactions β like, the exact ones you already know and love from DBI. same energy, same energy. π₯
and here's the tea: this is the low level interface that "txn_do" in KiokuDB requires. so KiokuDB shows up at your door like "hey, implement these and we can be friends." π€
π OPTIONAL METHODS π
so these ones? optional. you can do them, you don't have to. but like, they're kind of the moment.
txn_do $code, %callbacksβ this method should evaluate the code reference in the context of a transaction, inside aneval. if any errors get caught, the transaction should be aborted; otherwise it should be committed. it's giving"txn_do" in DBIx::Class::Schema, fr fr. and btw, the"rollback"callback should be fired when the transaction is going to be aborted. π
π REQUIRED METHODS π
these ones? mandatory. no skipping, no negotiating, the role will simply not be satisfied. main character obligations, iykyk.
txn_begin [ $parent_txn ]β begin a new transaction. β¨
this method can return a transaction handle, and that handle gets passed along later to "txn_commit" or "txn_rollback", whichever ends up being necessary. also, the current handle gets passed to nested calls of "txn_begin". so it's like... transactions within transactions. inception but make it databases. π
txn_commit $txnβ commit the transaction. done deal, ship it, slay. βtxn_rollback $txnβ rollback the transaction. nvm bestie, we pretend that never happened. π
π AUTHOR π
Yuval Kogman <nothingmuch@woobling.org> β iconic, we love them π«Ά
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
and that's the whole page, babe! π this was perl v5.34.0, dated 2022-05-23, and you just read the KiokuDB::Backend::Role::TXN (3pm) page all the way through. so proud of you. go write some transactions. bye bestie!! ππ§β¨
π¦ where this page comes from
- debian bookworm: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libkiokudb-perl 0.57-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms