[open-ils-commits] r18134 - in branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application: . Trigger (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Oct 2 09:48:01 EDT 2010
Author: miker
Date: 2010-10-02 09:47:59 -0400 (Sat, 02 Oct 2010)
New Revision: 18134
Modified:
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm
Log:
Backporting r18123 from trunk: Implement a process-local cache for event target fleshing -- particularly helpful with large event groups
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2010-10-02 06:04:05 UTC (rev 18133)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2010-10-02 13:47:59 UTC (rev 18134)
@@ -444,6 +444,29 @@
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;
@@ -495,12 +518,15 @@
$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;
}
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm 2010-10-02 06:04:05 UTC (rev 18133)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm 2010-10-02 13:47:59 UTC (rev 18134)
@@ -28,7 +28,7 @@
OpenILS::Application::Trigger::Event->new($_, $editor)
} @ids
],
- ids => \@ids,
+ ids => [ map { ref($_) ? $_->id : $_ } @ids ],
editor => $editor
} => $class;
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-10-02 06:04:05 UTC (rev 18133)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-10-02 13:47:59 UTC (rev 18134)
@@ -539,6 +539,7 @@
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...");
@@ -567,6 +568,7 @@
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...");
@@ -679,6 +681,7 @@
$e->editor->disconnect;
}
+ OpenILS::Application::Trigger::Event->ClearObjectCache();
return \%groups;
}
__PACKAGE__->register_method(
@@ -737,8 +740,6 @@
$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',
More information about the open-ils-commits
mailing list