cache and objectdatasource

Discussion in 'ASP .Net Web Controls' started by Trapulo, Apr 23, 2007.

  1. Trapulo

    Trapulo Guest

    Hello,
    I have a gridview that loads data from an objectdatasource. I want enable a
    sliding cache on objectdatasource, but I need to cache data only when one
    select parameter has a specific value (my select method requires 5
    parameters, and I want use cache only when one parameter has a specific
    value, to avoid consuming large amount of memory caching a lot of parameter
    sets).

    Is there any way to have this goal?

    thanks
     
    Trapulo, Apr 23, 2007
    #1
    1. Advertising

  2. Hi Trapulo,

    How are you doing?

    For the ObjectDataSource caching question you mentioned, are you using the
    default cache feature of the ObjectDataSource? If so, this cache feature is
    done by the ObjectDataSource internally and will use the query method's
    name and parameter colleciton as cachedKey. So far I haven't found any
    interface for us to manually disable/enable this cache depend on some
    certain query parameters. However, you can manually remove the cache of the
    ObjectDataSource through the ObjectDataSource.CacheKeyDependency property.
    See the following article:

    #ObjectDataSource in Depth (Part 3)
    http://www.manuelabadia.com/blog/PermaLink,guid,eaa3eed8-f997-43c4-8c30-78c2
    f72d0c86.aspx

    If you do need the capability of control the caching(of underlying data
    record set) behavior, I may consider programmatically use ASP.NET Cache
    object to cache the data in your data access class instead of
    ObjectDataSource's cache support.

    How do you tihnk?

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Apr 24, 2007
    #2
    1. Advertising

  3. Trapulo

    Trapulo Guest

    Hi Steven,
    I'm using default ObjectDataSource cache feature. My "select" method has
    some parameters defined, and most queries will use a small set of values
    (setting most of parameters to nothing), so I want cache their results to
    avoid most of round trip to database. I think that "cachedKey" property is
    not a solution, because it will clear all cache results and I need to
    selective use Cache, but when I don't use it for a single query I want that
    it remains in memory for the next.

    I thinks the best way is to use ASP.NET Cache object from ObjectDataSource:
    do you have any good reference you can suggest, to make a good
    implementation of this?

    Thanks


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Trapulo,
    >
    > How are you doing?
    >
    > For the ObjectDataSource caching question you mentioned, are you using the
    > default cache feature of the ObjectDataSource? If so, this cache feature
    > is
    > done by the ObjectDataSource internally and will use the query method's
    > name and parameter colleciton as cachedKey. So far I haven't found any
    > interface for us to manually disable/enable this cache depend on some
    > certain query parameters. However, you can manually remove the cache of
    > the
    > ObjectDataSource through the ObjectDataSource.CacheKeyDependency property.
    > See the following article:
    >
    > #ObjectDataSource in Depth (Part 3)
    > http://www.manuelabadia.com/blog/PermaLink,guid,eaa3eed8-f997-43c4-8c30-78c2
    > f72d0c86.aspx
    >
    > If you do need the capability of control the caching(of underlying data
    > record set) behavior, I may consider programmatically use ASP.NET Cache
    > object to cache the data in your data access class instead of
    > ObjectDataSource's cache support.
    >
    > How do you tihnk?
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    >
    > ==================================================
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    >
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    >
    > ==================================================
    >
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    Trapulo, Apr 24, 2007
    #3
  4. Thanks for your reply Trapulo,

    I haven't any definite reference on how to creating such class since it is
    more specific to data access component class development. I have ever
    discussed some similar questions in the newsgroup and you can search for my
    threads with some keywords like "objectdatasource", "Dataset"...

    http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
    se_thread/thread/9ab375efebcf4c63/c433a129b8d87a7e

    http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
    se_thread/thread/50824bfd534fa636/8ccee6bbf472c3a1

    A common approach is let your data access class(used in objectdatasource)
    always check the cache(with a generated key) and if cache not exists,
    initialize the cache and then return the cached object(as return value of
    your select method...). Also, you can programmtically specify the cache
    dependency type(such as file dependency or sql database dependency)

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Apr 26, 2007
    #4
  5. Trapulo

    Trapulo Guest

    Thank you Steven,
    I've implemented a custom logic in my select method, and I'm using Cache
    Object with a code like this:

    Dim cacheKey As String, cacheCountKey As String
    If [eval if may use cache] Then

    cacheKey = [values] & "-"c & startRowIndex.ToString & "-" &
    maximumRows.ToString

    cacheCountKey = [values] & "-"c

    If HttpContext.Current.Cache.Item(cacheKey) IsNot Nothing Then

    Return DirectCast(HttpContext.Current.Cache.Item(cacheKey), Data.DataSet)

    End If



    [... retrieve data...]



    If Not String.IsNullOrEmpty(cacheKey) Then

    HttpContext.Current.Cache.Add(cacheKey, out, Nothing,
    Now.AddMinutes(_cacheDurationMinutes), Nothing, CacheItemPriority.Low,
    Nothing)

    HttpContext.Current.Cache.Add(cacheCountKey, filter.TotalRows, Nothing,
    Now.AddMinutes(_cacheDurationMinutes), Nothing, CacheItemPriority.Low,
    Nothing)

    End If

    End If


    thanks


    "Steven Cheng[MSFT]" <> wrote in message
    news:p...
    > Thanks for your reply Trapulo,
    >
    > I haven't any definite reference on how to creating such class since it is
    > more specific to data access component class development. I have ever
    > discussed some similar questions in the newsgroup and you can search for
    > my
    > threads with some keywords like "objectdatasource", "Dataset"...
    >
    > http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
    > se_thread/thread/9ab375efebcf4c63/c433a129b8d87a7e
    >
    > http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
    > se_thread/thread/50824bfd534fa636/8ccee6bbf472c3a1
    >
    > A common approach is let your data access class(used in objectdatasource)
    > always check the cache(with a generated key) and if cache not exists,
    > initialize the cache and then return the cached object(as return value of
    > your select method...). Also, you can programmtically specify the cache
    > dependency type(such as file dependency or sql database dependency)
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    Trapulo, Apr 27, 2007
    #5
  6. Thanks for your followup.

    Glad to be of assistance :)

    Sincerely,

    Steven Cheng
    Microsoft MSDN Online Support Lead
     
    Steven Cheng[MSFT], Apr 30, 2007
    #6
    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. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    589
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,293
    vMike
    Jan 20, 2004
  3. John
    Replies:
    2
    Views:
    1,195
  4. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    250
    Steven Cheng[MSFT]
    Mar 23, 2006
  5. kevin
    Replies:
    1
    Views:
    381
    Kairi Zikpin
    Jul 21, 2006
Loading...

Share This Page