NAME
UR::Context::AutoUnloadPool - Automatically unload objects when scope ends
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
UR Objects retrieved from the database normally live in the object cache for the life of the program. When a UR::Context::AutoUnloadPool is instantiated, it tracks every object loaded during its life. The Pool's destructor calls unload() on those objects.
Changed objects and objects loaded before before the Pool is created will not get unloaded.
METHODS
- create
-
my $guard = UR::Context::AutoUnloadPool->create();
Creates a Pool object. All UR Objects loaded from the database during this object's lifetime will get unloaded when the Pool goes out of scope.
- delete
-
$guard->delete();
Invalidates the Pool object. No objects are unloaded. When the Pool later goes out of scope, no objects will be unloaded.
SEE ALSO
UR::Object, UR::Context