[Rt-commit] [rtir] 01/01: Use the new MakeClicky cache added to RT

Kevin Falcone falcone at bestpractical.com
Fri Apr 25 14:21:04 EDT 2014


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

falcone pushed a commit to branch 3.0/makeclicky-cache
in repository rtir.

commit 47fb4c9cee39b87ad0256ef6c4c92f795c959fb6
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Apr 25 13:57:08 2014 -0400

    Use the new MakeClicky cache added to RT
    
    On a new enough version of RT, this subroutine will be executed on any
    MakeClicky call.  This allows us to cache for 6 hours the results of
    generating links to Lookup.html (in particular, on tickets with lots of
    IPs in history, this is a huge win).  Even on tickets needing minimal
    processing, it helps speed up display.
    
    One interesting quirk of this code is that MakeClicky is run on Whois
    lookups and traceroute.  Traceroute provides no useful details (not even
    the ticket) so it's kind of a lost cause.  Whois on the other hand
    provides lookup_params, and when we get that we should punt on the
    caching so we don't provide links to the wrong ticket object.
---
 html/Callbacks/RTIR/Elements/MakeClicky/Default | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index 876c188..ad3519b 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -238,6 +238,30 @@ ${$ARGS{handle}} = sub {
     return $handle->(%args);
 };
 
+my $cache = ${$ARGS{cache}};
+unless (defined $cache) {
+    ${$ARGS{cache}} = sub {
+        my $type = shift;
+        my $content = shift;
+        if ($type eq 'fetch') {
+            my $parent_args = $m->caller_args(1);
+            return if $parent_args->{lookup_params};
+
+            require Digest::SHA;
+            return $m->cache->get(Digest::SHA::sha512_base64($$content));
+        } elsif ($type eq 'store') {
+            require Digest::SHA;
+            $m->cache->set(Digest::SHA::sha512_base64($$content),
+                           $$content,
+                           "6 hours");
+        } else {
+            RT->Logger->error("Invalid type $type passed to MakeClicky's cache");
+        }
+    }
+} else {
+    RT->Logger->info("Someone else defined a MakeClicky cache, skipping ours");
+}
+
 %{$ARGS{actions}} = ( %{$ARGS{actions}}, %actions );
 push @{$ARGS{types}}, @types;
 

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


More information about the rt-commit mailing list