KiokuD...::Lazy(3pm)
β¨ NAME β¨
KiokuDB::Meta::Attribute::Lazy β the trait that makes your attributes load lazily, bestie π€β¨
(it's a Perl 3pm page, from the User Contributed Perl Documentation collection, if you were wondering where you wandered into π«Ά)
πΈ VERSION πΈ
version 0.57 β yes queen, that's the one π
π SYNOPSIS π
okay so picture this: you're in your class, right? and you want bar to be lazy. boom. here's the whole vibe:
# in your class:
package Foo;
use KiokuDB::Class;
has bar => (
traits => [qw(KiokuDB::Lazy)],
isa => "Bar",
is => "ro",
);
and then, like, later on:
# Later:
my $foo = $dir->lookup($id);
# bar is not yet loaded, it will be lazily fetched during this call:
$foo->bar;
see how bar is just sitting there not loaded yet? iconic. it gets lazily fetched during that call. the way that accessor does its job... π
π¦ DESCRIPTION π¦
so this is a Moose::Meta::Attribute trait, and what it does is give you lazy loading on a per field basis for objects stored in KiokuDB. per field!! you pick and choose, no commitment, we love that for you π
here's the thing β instead of doing the whole proxy-object song and dance with AUTOLOAD, overloading, or similar hacks (π not the hacks), you just declaratively specify which attributes you want to make lazy. that's it. and it gets done cleanly through the MOP. clean girl aesthetic, but for metaprogramming β¨
how's it actually work under the hood? so glad you asked. it uses a placeholder object, KiokuDB::Thunk, which holds references to the ID and the linker. then KiokuDB::Meta::Instance knows to swap that placeholder out for the actual loaded object whenever it gets fetched from the object by an accessor. like a glow-up but automatic π§
π AUTHOR π
Yuval Kogman <nothingmuch@woobling.org> β shoutout to the icon who wrote this π«Ά
π 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.
okay that's the whole page, no cap. this was KiokuD...::Lazy(3pm) (aka KiokuDB::Meta::Attribute::Lazy), built with perl v5.34.0 and dated 2022-05-23 πΈ mwah, go make some lazy attributes, you got this 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