Re: Default Membership Provider // Caching?
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Wed, 20 Jun 2007 16:45:56 -0400
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;
}
}
.
- References:
- Default Membership Provider // Caching?
- From: sloan
- Re: Default Membership Provider // Caching?
- From: sloan
- Default Membership Provider // Caching?
- Prev by Date: Control loosing their status...
- Next by Date: Re: can someone explain me why this does not work?
- Previous by thread: Re: Default Membership Provider // Caching?
- Next by thread: code problem error
- Index(es):