Solved

Membership Provider session vs cache

Posted on 2010-11-20
4
848 Views
Last Modified: 2012-08-14
Hello.

I've created a custom membership and role provider for our site. Essentially it loads a dataset of commonly used user data into that user's session after authentication. This way we limit some of the DB calls throughout the site. All updates work OK since I first update the session dataset then then database when updates occur.

One issue I've now run into is that the user's can change their names through an admin page that is queued up. The admins then accept/deny the change. If they accept the change, the user info is updated in the database... but not the user's session object (obviously). This creates a problem with the user data not being updated when they are logged in.

Anyone have any good ideas on how to handle the admin update so as not to compromise the data integrity when the user is logged on?

Is there any reason I can't hold the user's session dataset in the applications cache instead? That way the admins and the users are updating the same dataset when the user is logged in.
0
Comment
Question by:dacIT
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:ToAoM
ID: 34182778
Place the details in the Application object, that is kind of the Session object, but then for the whole application. You will need to implement a readerwriterlock on the variable, otherwise different threads can override each others changes.

Here is a (rather old) article on how to use the Application scope.
http://www.eggheadcafe.com/articles/20030211.asp

One issue with this setup is that the Application scope is linked to the AppPool the site runs under, so if you have multiple hosts in your setup, each will have its own instance of the data. You should consider using AppFabric Caching as an alternative if this scenario applies to you.
0
 
LVL 7

Author Comment

by:dacIT
ID: 34245614
Wow thanks. Hadn't even heard of the application variable.

It still seems to me that the global cache might be better in that I can purge that on a time schedule pretty easily after so many minutes of disuse.

Is the HttpRuntime.Cache object the same across server farms?
0
 
LVL 17

Accepted Solution

by:
ToAoM earned 500 total points
ID: 34246179
Not, the cache is not synced across farms, neither is the application variable.

If you use AppFabric Caching, you can have a centralized cache cluster.
0
 
LVL 7

Author Closing Comment

by:dacIT
ID: 34249875
Thanks for your help!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now