diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2013-01-05 17:04:20 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2013-01-05 17:04:20 +0000 |
| commit | ee0e699acdd21895d3d319d9d50be3059884852d (patch) | |
| tree | de3f313d1b456bd1c6d9dd05842bd5cfe14f9ca4 /src | |
| parent | faf6f1ae7b5423a48950104b9f762e8b0514feaf (diff) | |
| download | rabbitmq-server-git-ee0e699acdd21895d3d319d9d50be3059884852d.tar.gz | |
optimisation: improve performance of permission cache
Don't update the cache when the permission is already in it. This
saves list munching and a 'put' at the expense of no longer being
strictly LRU, but that only affects pathological cases.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_channel.erl | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 1af60de8b4..11a117ee1c 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -432,15 +432,13 @@ check_resource_access(User, Resource, Perm) -> undefined -> []; Other -> Other end, - CacheTail = - case lists:member(V, Cache) of - true -> lists:delete(V, Cache); - false -> ok = rabbit_access_control:check_resource_access( - User, Resource, Perm), - lists:sublist(Cache, ?MAX_PERMISSION_CACHE_SIZE - 1) - end, - put(permission_cache, [V | CacheTail]), - ok. + case lists:member(V, Cache) of + true -> ok; + false -> ok = rabbit_access_control:check_resource_access( + User, Resource, Perm), + CacheTail = lists:sublist(Cache, ?MAX_PERMISSION_CACHE_SIZE-1), + put(permission_cache, [V | CacheTail]) + end. clear_permission_cache() -> erase(permission_cache), |
