UR::Co...oadPool(3pm)
β¨ NAME β¨
UR::Context::AutoUnloadPool β the module that auto-unloads your objects the second the scope ends, bestie π
π SYNOPSIS π
my $not_unloaded = Some::Class->get(...);
do {
my $guard = UR::Context::AutoUnloadPool->create();
my $object = Some::Class->get(...); # load an object from the database
... # load more things
}; # $guard goes out of scope - unloads objects
π¦ DESCRIPTION π¦
okay so here's the tea β β UR Objects you pull out of the database normally just vibe in the object cache for the entire life of the program. Forever. No cap. They never leave. π
But when you instantiate a UR::Context::AutoUnloadPool, it starts tracking every single object loaded during its lifetime. Then the Pool's destructor hits unload() on all of them. Cleanup era. β¨
Two things that do NOT get unloaded, and this is important:
- objects that were changed π«
- objects that got loaded before the Pool was created π«
π METHODS π
πΈ create
my $guard = UR::Context::AutoUnloadPool->create();
Makes you a Pool object, periodt. Every UR Object loaded from the database during this object's lifetime is getting unloaded when the Pool goes out of scope. That's the whole job and it does it flawlessly, honestly iconic π
π delete
$guard->delete();
Invalidates the Pool object. No objects are unloaded. π So when the Pool later goes out of scope, nothing gets unloaded either. It's giving "never mind, we're keeping all of it." Not me undoing my own cleanup π
π SEE ALSO π
UR::ObjectUR::Context
iykyk π«Ά
perl v5.32.1 Β· 2022-01-17 β that's the source, version and date of this lil gem, bestie. go forth and unload responsibly ππ§β
π¦ where this page comes from
- debian bookworm: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms