[freeside-commits] freeside/FS/FS access_user.pm, 1.15.2.1, 1.15.2.2

Ivan,,, ivan at wavetail.420.am
Sat Jan 31 01:53:17 PST 2009


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv9971

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	access_user.pm 
Log Message:
cache the results of ACL queries, should improve performance of customer view page for customers with shitloads of packages/services, RT#4696

Index: access_user.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/access_user.pm,v
retrieving revision 1.15.2.1
retrieving revision 1.15.2.2
diff -u -d -r1.15.2.1 -r1.15.2.2
--- access_user.pm	29 Feb 2008 02:29:59 -0000	1.15.2.1
+++ access_user.pm	31 Jan 2009 09:53:15 -0000	1.15.2.2
@@ -381,6 +381,17 @@
 
 sub access_right {
   my( $self, $rightname ) = @_;
+
+  #some caching of ACL requests for low-hanging fruit perf improvement
+  #since we get a new $CurrentUser object each page view there shouldn't be any
+  #issues with stickiness
+  if ( $self->{_ACLcache} ) {
+    return $self->{_ACLcache}{$rightname}
+      if exists($self->{_ACLcache}{$rightname});
+  } else {
+    $self->{_ACLcache} = {};
+  }
+
   my $sth = dbh->prepare("
     SELECT groupnum FROM access_usergroup
                     LEFT JOIN access_group USING ( groupnum )
@@ -389,10 +400,14 @@
       WHERE usernum = ?
         AND righttype = 'FS::access_group'
         AND rightname = ?
+      LIMIT 1
   ") or die dbh->errstr;
   $sth->execute($self->usernum, $rightname) or die $sth->errstr;
   my $row = $sth->fetchrow_arrayref;
-  $row ? $row->[0] : '';
+
+  #$row ? $row->[0] : '';
+  $self->{_ACLcache}{$rightname} = ( $row ? $row->[0] : '' );
+
 }
 
 =back



More information about the freeside-commits mailing list