KiokuD...le::TXN(3pm)

πŸ“¦
version 0.57 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– 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 an eval. 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 🫢


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