diff options
author | ivan <ivan> | 2009-01-31 09:53:15 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-01-31 09:53:15 +0000 |
commit | 7ebd7ac91d49b174be34057fc53498c5d5b89cb1 (patch) | |
tree | 68726c2baddb24b0781ba29ba9ab80b2af54d8e7 | |
parent | 036e81fffeb1358491c285205cac74f47580ef22 (diff) |
cache the results of ACL queries, should improve performance of customer view page for customers with shitloads of packages/services, RT#4696
-rw-r--r-- | FS/FS/access_user.pm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm index 271340dff..860ca84ce 100644 --- a/FS/FS/access_user.pm +++ b/FS/FS/access_user.pm @@ -381,6 +381,17 @@ group membership, eventually also via user overrides). 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 @@ sub access_right { 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 |