What happens when I enable caching?

8 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 19 Feb 2010 Link to this post

    Ok, so I enabled the cache in the options for my OA project...

    So lets say I have a Label on my aspx page which on page load I open my scope, run a linq query to get my object, and set the value of the label to the DB value...and on page unload I dispose of the scope.

    ....so then I click a button which posts back to the server...

    Would then would happen when the above query\scope runs again...new DB query or the query is cached in OA and just gives me the data again?
  2. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 23 Feb 2010 Link to this post

    Hi Steve,

    As per my understanding there's 1st level cache and 2nd level cache.

    Let's take the first level - eh yeah - first :-) :

    This cache lives and dies with the object scope. So if you dispose your scope and creates a new one for example between postbacks a new query will hit the DB. If you keep the scope alive (you do not dispose it), queries for the same object (one that is already in the object scope cache) will fetch it from the cache.

    The 2nd one

    This cache lives separately from the object scopes and is therefore shared by object scopes. So in your scenario (where you create-dispose with each thread/request) it is a perfect match..  On the second query for the same object it will go to the second level cache for the object instead of hitting the DB.   Also... the 2nd level cache can be distributed..so caches living in different appdomains can be sync'ed against each other.

    All of the above is per my understanding. We use the 2nd level cache in our WCF powered solution and it boosts performance nicely.

    Regards

    Henrik
  3. DevCraft banner
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 23 Feb 2010 Link to this post

    Well that sounds awesome :)  I just turned on L2 for the hell of it, sounds like it's exactly what I need!
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 24 Feb 2010 Link to this post

    Hello Steve,

    Additional information about the caching mechanism of the Telerik OpenAccess ORM can be found in the following articles: “2nd Level Cache” and “Caching optimization” as well as the blog post “OpenAccess ORM Second Level Cache API”.
    I hope the information will be helpful for you.

    All the best,
    Damyan Bogoev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 26 Feb 2010 Link to this post

    This doesn't actually seem to be working...a SQL profile on the DB still shows a simple object query hitting the DB every time

    //Query
    Auth auth = scope.Extent<Auth>().Where(x => x.AuthID == AuthID).FirstOrDefault();

    //Profile result every page refresh
    exec sp_execute 4,@p0='139A9919-DFA1-450C-BF6E-9DF25253A9F3',@__TAKE=1
  7. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 03 Mar 2010 Link to this post

    Hello Steve,

    You could review the caching example from our code library: Caching – C#.NET and Caching – VB.NET as well as the example from our demo site.
    You could find them useful for correct settings of the caching mechanism in your application.
    I hope the provided information will be helpful for you.

    Sincerely yours,
    Damyan Bogoev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. gfkrt
    gfkrt avatar
    2 posts
    Member since:
    Sep 2008

    Posted 21 Jul 2011 Link to this post

    Hello Henrik,

    could you please describe how you use the l2 cache in your wcf application?

    I also turned the cache on in our wcf application, but I see no differences in performance.

    Thanks & kind regards,
    Peter
  9. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 01 Aug 2011 Link to this post

    Hello gfkrt,

    Sorry for the late response... Vacation. :-)

    You should be aware that you need the L2 cache settings in your web.config if your WCF services is hosted by IIS
Back to Top
DevCraft banner