Default Membership Provider // Caching?

Discussion in 'ASP .Net' started by sloan, Jun 19, 2007.

  1. sloan

    sloan Guest

    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..............
    sloan, Jun 19, 2007
    #1
    1. Advertising

  2. 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
    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "sloan" wrote:

    > 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..............
    >
    >
    >
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jun 19, 2007
    #2
    1. Advertising

  3. look into using the "profile" object

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


    "sloan" <> wrote in message news:e%23u$...
    > 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..............
    >
    >
    >
    >
    Jon Paal [MSMD], Jun 19, 2007
    #3
  4. sloan

    sloan Guest

    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.



    .........




    "Peter Bromberg [C# MVP]" <> wrote in
    message news:...
    > 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
    > --
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > Short urls & more: http://ittyurl.net
    >
    >
    >
    >
    > "sloan" wrote:
    >
    > > 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..............
    > >
    > >
    > >
    > >
    > >
    sloan, Jun 20, 2007
    #4
  5. sloan

    sloan Guest

    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;



    }

    }
    sloan, Jun 20, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BS
    Replies:
    3
    Views:
    2,043
    Alvin Bruney [MVP]
    Jun 17, 2004
  2. sloan
    Replies:
    5
    Views:
    1,496
    sloan
    Jun 4, 2006
  3. thomas
    Replies:
    4
    Views:
    744
    thomas
    Oct 15, 2006
  4. J
    Replies:
    0
    Views:
    981
  5. sloan
    Replies:
    1
    Views:
    497
    Chad Scharf
    Jul 3, 2007
Loading...

Share This Page