KiokuD...ontent(3pm)

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

✨ KiokuDB::Role::ID::Content πŸ’–

okay bestie, welcome to KiokuDB::Role::ID::Content β€” it's giving Content dependent object IDs, and it's from the User Contributed Perl Documentation section of the manual (that's the 3pm vibe, iykyk) 🫢

🌸 VERSION

version 0.57 β€” yes ma'am, that's the one ✨


πŸŽ€ SYNOPSIS

package BLOB;
use Moose;

use Digest::SHA1;

with qw(KiokuDB::Role::ID::Content);

sub kiokudb_object_id {
    my $self = shift;
    sha1_hex($self->data);
}

has data => (
    isa => "Str",
    is  => "ro",
    required => 1,
);

like. look at it. with qw(KiokuDB::Role::ID::Content); and then boom, you define kiokudb_object_id yourself and the ID comes from the content. iconic behavior honestly πŸ’…


πŸ’« DESCRIPTION

So here's the tea, bestie: this is a role for KiokuDB::Role::Immutable objects whose IDs depend on their content β€” or, in the cooler words, content addressable objects 🌈

The canonical example? A string identified by its SHA-1 hash, exactly like the "SYNOPSIS" is showing off. chef's kiss, no notes πŸ‘‘

Objects that do this role are never updated in the database β€” literally the same deal as KiokuDB::Role::Immutable objects. Once they're in, they're in. main character energy, they don't do rewrites πŸ’€

And here's the little bonus that lowkey slays: it is not an error to insert such objects twice, because the objects are assumed to be identical. Double-inserting? Not a problem. The vibe check passes. βœ…

🌟 AUTHOR

Yuval Kogman <nothingmuch@woobling.org> β€” thank you for your service 🫢


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. fr fr πŸ’š


okay so that's the whole page, and for the cute sign-off: this lil doc is running on perl v5.34.0, dated 2022-05-23, and it lives in the manual as KiokuD...ontent(3pm) πŸ’– bye bestie, go hash something πŸŽ€βœ¨

πŸ“¦ where this page comes from