Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Default Membership Provider // Caching?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sloan - 19 Jun 2007 15:22 GMT
It looks like the default Membership Provider (and Role Provider) always
goes to the database to get its info.
(GetUsers, GetRoles, etc , etc).

I guess I'm going to roll my own, because I am going to need a cached
solution to avoid the database hits.
(My roles and users seldom/never change after a project rollout)

I wanted to ask in general (before I start the work of a custom membership
provider).

A.  Am I right with my assumption?  (no caching)
B.  Is there some .config way to get caching from teh default providers that
I don't know about?
C.  I really don't have any issue with ~~how the default ones work, just the
non caching.  You think I might be able to use inheritance and just address
those issues?
D.  If the above answers eventually lead to "roll your own", does anyone
know of a project/source showing a good "roll your own" solution.

I just got back from a long weekend trip in the car with my wife and 3 dogs.
So I'm a little on the "tuckered out" side today.

Thanks..............
Peter Bromberg [C# MVP] - 19 Jun 2007 18:03 GMT
Hmm, 1 wife and 3 dogs? That could be part of the problem.
Anyway, the only caching I know of is the CacheRolesInCookie directive.
If you really think you need caching (and in fact you may not really need it
at all, so you should test first under load), then you are going to have to
roll your own.
Scott Guthrie has some nice links to sample custom providers on his blog.

Peter
Signature

Site:  http://www.eggheadcafe.com
UnBlog:  http://petesbloggerama.blogspot.com
Short urls & more:    http://ittyurl.net

> It looks like the default Membership Provider (and Role Provider) always
> goes to the database to get its info.
[quoted text clipped - 20 lines]
>
> Thanks..............
sloan - 20 Jun 2007 19:45 GMT
Public Class ModifiedSqlMembershipProvider
  Inherits SqlMembershipProvider

http://www.devx.com/asp/Article/29256/0/page/3

It looks like if I'm mostly happy with the default provider, I can just
inherit from SqlMembershipProvider.

Well, that's what that URL says.  I'm gonna check it out.

........

> Hmm, 1 wife and 3 dogs? That could be part of the problem.
> Anyway, the only caching I know of is the CacheRolesInCookie directive.
[quoted text clipped - 29 lines]
> >
> > Thanks..............
sloan - 20 Jun 2007 21:45 GMT
Here is some code to start (a future reader) out in the right direction:

I have a formal framework to cache data.  So I had to leave that part out.
But the method are ensapsulated enough to get the idea.

If you're interested in my framework idea, check this out:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!125.entry

public class CachedSqlRoleProvider : SqlRoleProvider

{

private readonly string KEY_ALL_ROLES = "AllRolesKey";

private string[] GetCachedRoles()

{

//I have a Framework piece to cache data

//Implement your caching strategry here

return null;

}

private void CacheRoles(string[] roles)

{

//I have a Framework piece to cache data

//Implement your caching strategry here

}

public override string[] GetAllRoles()

{

string[] returnValues;

returnValues = this.GetCachedRoles();

//if there wasn't anything in the Cache, to use the base method to get a
fresh copy
if (null == returnValues)

{

//this will end up hitting the db
returnValues = base.GetAllRoles();

if (null != returnValues)

{

//we got them, cache them for next time

this.CacheRoles(returnValues);

}

}

return returnValues;

}

}
Jon  Paal [MSMD] - 19 Jun 2007 18:19 GMT
look into using the "profile" object

http://www.codersource.net/published/view/303/website_profile_object_in_asp_net.aspx

> It looks like the default Membership Provider (and Role Provider) always
> goes to the database to get its info.
[quoted text clipped - 20 lines]
>
> Thanks..............

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.