authorization plugin caching

I love the authorization[1] plugin and use it in all my RoR applications
to enhance acts_as_authenticated with roles.

My biggest problem with it was that it queries the DB for every permit
or has_role? function call. On some pages i needed to check roles
multiple times and the database load would have made it unusable in
production environments.

The attached patch caches the current_user's roles at every page load.

This is my first RoR plugin patch, so if anyone is interested i would
love it if it got tested a little. At present it only caches
current_user's roles, in a future version i could enhance it cache every
permit? or has_role? call

Cheers,
Radu Spineanu

[1] http://www.writertopia.com/developers/authorization

authorization_cache.patch.gz (1 KB)