KiokuD...:Memory(3pm)

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

πŸ’– KiokuD...:Memory β€” the tea πŸ’–

okay so bestie, you found the page for KiokuDB::Backend::Role::TXN::Memory, which is a Perl thing (3pm, you know the vibe) πŸ‘‘ lowkey it's a whole role that gives you transactions, but, like, in memory. let's get into it 🫢


✨ VERSION ✨

version 0.57 β€” that's the one, no cap πŸ’…


✨ SYNOPSIS ✨

so this is how you'd use it, fr fr:

with qw(KiokuDB::Backend::Role::TXN::Memory);

sub commit_entries {
    my ( $self, @entries ) = @_;

    # atomically apply @entries

    # deleted entries have the deleted flag set
    # if an entry has no 'prev' entry it's an insert
    # otherwise it's an update
}

see how the comments are doing all the explaining? iconic of them 🌸


✨ DESCRIPTION ✨

okay so here's the whole deal: this backend hands you in memory transactions for backends that do support atomic modification of data, but do not support the full commit/rollback situation. it's giving "we can do some of it, bestie" 😭

the way it works is it buffers every operation in memory. entries get kept alive so that read operations can go straight to the live entry β€” even for objects that are out of scope. slay πŸ’…

this implementation gives you repeatable read level isolation. and listen, because this part matters: durability, concurrency and atomicity are still the responsibility of the backend. not this role's problem, bestie. it's just the memory-buffering girly 🧚


✨ REQUIRED METHODS ✨

if you're the backend, these are the ones you have to bring to the group chat. no ghosting 🫢

🌸 commit_entries

insert, update or delete entries as specified, basically.

this operation should either fail or succeed atomically β€” no half-committing, that's not the vibe πŸ™ˆ

here's the ruleset:

  • entries with "deleted" should be removed from the database
  • entries with a "prev" entry should be inserted
  • all other entries should be updated

also, heads up: multiple entries may be given for a single object. for instance, an object that was first inserted and then modified will have an insert entry and an update entry. two entries, one object, it's giving main character energy ⭐

🌸 get_from_storage

this one should be the same as "get" in KiokuDB::Backend.

when no memory buffered entries are available for the object, one is fetched from the backend. that's the whole thing, bestie πŸ’œ

🌸 exists_in_storage

required as of KiokuDB version 0.37. periodt.

a fallback implementation is provided, but bestie, do not use it β€” it will issue a deprecation warning. so, like, don't. 😭


✨ AUTHOR ✨

Yuval Kogman <nothingmuch@woobling.org> β€” shoutout to the icon who wrote this πŸ’–


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. 🌈


and that's the page, bestie!! πŸŽ€ one last lil sign-off for the record books: this was rendered by perl v5.34.0 and dated 2022-05-23, and yes, the title at the top is KiokuD...:Memory(3pm) β€” go forth and commit atomically πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from