my $event_id = shift;
my $e = OpenILS::Application::Trigger::Event->new($event_id);
+ OpenILS::Application::Trigger::Event->ClearObjectCache();
if ($e->validate->valid) {
$logger->info("trigger: Event is valid, reacting...");
my $events = shift;
my $e = OpenILS::Application::Trigger::EventGroup->new(@$events);
+ OpenILS::Application::Trigger::Event->ClearObjectCache();
if ($e->validate->valid) {
$logger->info("trigger: Event group is valid, reacting...");
$e->editor->disconnect;
}
+ OpenILS::Application::Trigger::Event->ClearObjectCache();
return \%groups;
}
__PACKAGE__->register_method(
$logger->info("trigger: run_all_events completed firing events for grouped event def=$def");
}
}
-
-
}
__PACKAGE__->register_method(
api_name => 'open-ils.trigger.event.run_all_pending',
return $class;
}
+my %_object_by_path_cache = ();
+sub ClearObjectCache {
+ for my $did ( keys %_object_by_path_cache ) {
+ my $phash = $_object_by_path_cache{$did};
+ for my $path ( keys %$phash ) {
+ my $shash = $phash{$path};
+ for my $step ( keys %$shash ) {
+ my $fhash = $shash{$step};
+ for my $ffield ( keys %$fhash ) {
+ my $lhash = $fhash{$ffield};
+ for my $lfield ( keys %$lhash ) {
+ delete $$lhash{$lfield};
+ }
+ delete $$fhash{$ffield};
+ }
+ delete $$shash{$step};
+ }
+ delete $$phash{$path};
+ }
+ delete $_object_by_path_cache{$did};
+ }
+}
+
sub _object_by_path {
my $self = shift;
my $context = shift;
$ed->xact_begin || return undef;
}
- $obj = $ed->$meth(
- ($multi) ?
- { $ffield => $context->$lfield() } :
- $context->$lfield()
- );
+ $obj = $_object_by_path_cache{$self->event->event_def->id}{join('.',@$path)}{$step}{$ffield}{$context->$lfield()} ||
+ $ed->$meth(
+ ($multi) ?
+ { $ffield => $context->$lfield() } :
+ $context->$lfield()
+ );
+
+ $_object_by_path_cache{$self->event->event_def->id}{join('.',@$path)}{$ffield}{$context->$lfield()} ||= $obj;
if ($self->standalone) {
$ed->xact_rollback || return undef;