ASP.NET - caching user privileges
I'm sorry for my english.
In my ASP.NET MVC application I have users controlled by ASP.NET Membership and user groups which are stored in database by means of my business-logic. Also, I implemented ACL (access control list) architecture to control user access to entities in my application so i have a number of records (stored in DB table) of structure User-Object-Privilegy-Value.
To ensure that a user has access to certain entity (or object) i need to re-create ever time the hierarchy of all groups where the user is the participant and find all privileges for that subjects.
In the purpose of optimization i need to cache that information in the application cache but i also need to monitor if any user, user group or privilegy has changed to invalidate that cached records.
I could implement it by some ways but i'd like to know the better way.
开发者_如何学CDid anyone has the same expirience? What is the best solution for caching user privileges?
There are built-in caching tools, but none that will cache and invalidate a specific, custom structure with enough knowledge to handle a hierarchy as you describe automatically. You will have to write your own.
However, you can still use the built-in CacheDependency system to be the underlying framework. You will have to extend the class and subscribe to the various change notifiers yourself.
精彩评论