[Rt-commit] [rtir] 01/01: add caching to RT::IR::Queues and flushing to RT::IR::Queues and RT::IR::CustomFields on every request

Dustin Graves dustin at bestpractical.com
Fri Feb 5 14:39:17 EST 2016


This is an automated email from the git hooks/post-receive script.

dustin pushed a commit to branch 3.4/remove-hardcoded-queue-names
in repository rtir.

commit 43a2abf2bbbd76b84f1e1bb190fce5b4b8f82319
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Fri Feb 5 19:38:30 2016 +0000

    add caching to RT::IR::Queues and flushing to RT::IR::Queues and RT::IR::CustomFields on every request
---
 lib/RT/IR.pm | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 485f0b7..5e74f91 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -238,22 +238,30 @@ Returns a list of the core RTIR Queue names
 
 =cut
 
+{ my @cache;
 sub Queues {
-    my $queues = RT::Queues->new( RT->SystemUser );
+    unless (@cache) {
+        my $queues = RT::Queues->new( RT->SystemUser );
 
-    $queues->Limit(
-        FIELD => 'Lifecycle',
-        OPERATOR => 'IN',
-        VALUE => \@LIFECYCLES,
-    );
+        $queues->Limit(
+            FIELD => 'Lifecycle',
+            OPERATOR => 'IN',
+            VALUE => \@LIFECYCLES,
+        );
 
-    my @rtir_queues;
-    while (my $queue = $queues->Next) {
-        push @rtir_queues, $queue->Name;
+        while (my $queue = $queues->Next) {
+            push @cache, $queue->Name;
+        }
     }
-    return @rtir_queues;
+    return @cache;
 }
 
+sub FlushQueuesCache {
+    @cache = ();
+    return 1;
+} }
+
+
 =head2 Lifecycles
 
 Return a list of the core RTIR lifecycle names
@@ -718,6 +726,18 @@ sub FlushCustomFieldsCache {
     return 1;
 } }
 
+{
+    no warnings 'redefine';
+
+    # flush caches on each request
+    require RT::Interface::Web::Handler;
+    my $orig_CleanupRequest = RT::Interface::Web::Handler->can('CleanupRequest');
+    *RT::Interface::Web::Handler::CleanupRequest = sub {
+        RT::IR::FlushCustomFieldsCache();
+        RT::IR::FlushQueuesCache();
+        $orig_CleanupRequest->();
+    };
+}
 
 sub FilterRTAddresses {
     my $self = shift;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list