Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have an Azure site with umbraco 4.7.1 running on it. On a lot of my pages I display different information based on if a user is in a role or not. I have MVCMiniProfiler installed and it's often the longest running task on my page. Usually around 400ms.
I'm trying to make it faster. I've looked at the umbraco code and it looks like here's how it's implimented.
It looks like the Umbraco implimentation requires two round trips to see if a user is in a role. One to get the role and one to see if that user is in the role.
new MemberGroup(SqlHelper.ExecuteScalar<int>( "select id from umbracoNode where Text = @text and nodeObjectType = @objectType", SqlHelper.CreateParameter("@text", Name), SqlHelper.CreateParameter("@objectType", _objectType))); return SqlHelper.ExecuteScalar<int>("select count(member) from cmsMember2MemberGroup where member = @member and memberGroup = @memberGroup", SqlHelper.CreateParameter("@member", memberId), SqlHelper.CreateParameter("@memberGroup", Id)) > 0;
It seems to me that I should override UmbracoRoleProvider. I could then override IsUserInRole and do my own implimentation.
Here's the logic I was thinking of for that:
1) Check local cache for user role list.
2) Check Azure cache for user role list.
3) Make one call to the database to check if that user is in that role.
If it gets to steps 2 or 3 I would update the correct caches.
I'd also add an index to umbracoNode that would span nodeobjecttype and text. I'd also change it from count() to a LINQ first, which I believe does a top(1) which should be faster.
Does anyone approve or disapprove of this logic? Notice any problems or anything that could be improved? I'll have everything timed with MVCMiniProfiler so I'll post the results back to this post.
This seems like a fine scenario to me. Would be lovely if you could submit it as a pull request to the Umbraco source so that everybody can benefit from this optimization.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted