Refreshing the cache

5 posts, 0 answers
  1. Christian
    Christian avatar
    81 posts
    Member since:
    Aug 2008

    Posted 08 Apr 2009 Link to this post

    Hi,

    we use OpenAccess as the link between the database on a MS SQL Server an our classes. All works fine an the cache is working. But in some cases we want to refresh the content of all instances on the client side against the database.
    I found no way to refresh the hole cache in one step.

    Thanks.
    Christian  
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 14 Apr 2009 Link to this post

    Hi Christian,

    the most easy way to do this is to start a new transaction (scope.Transaction.Begin()) as this method marks all content in the scope as being outdated. The reason for this is that per default, we want a modifying transaction to be valid from the start. Another way is to obtain a new scope and proceed working there.

    If you are referring to the 2nd Level Cache (the one shared by all object scopes in an AppDomain), there is currently no public API to perform eviction.

    Kind regards,
    Thomas
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Christian
    Christian avatar
    81 posts
    Member since:
    Aug 2008

    Posted 17 Apr 2009 Link to this post

    Hi,
    thank you for your answer, but that is not my goal. In my scenario I read a Resulset (a generic list of custom objects (list<t>)) from the database and used it as a datasource for a grid. My goal is to update the results in an easy way from the database, because the member of the results can be updated in the meantime from another user.
    In your documentation are two methods 'refresh' an 'retrieve'. In both ways the explanation is a little bit short. At the moment I try to write some source code to use the retrieve method with generic list of all my custom objects.

    Any hints are welcome.
    Christian
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 20 Apr 2009 Link to this post

    Hi Christian,
    If you do not start a new transaction the retrieve method will only load data that is not yet in memory. For all data that you actually display in the grid nothing will happen. The best way is to rollback the actual transaction, start a new one and reexecute the query. This will clear the ObjectScope cache and regenerate the query result.

    The other way is to use Refresh() this will reload the data from the database and overwrite the data in memory.

    Greetings,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Robert
    Robert avatar
    40 posts
    Member since:
    Jul 2008

    Posted 21 Apr 2009 Link to this post

    Hi Christian,

    Are you aware of the second level cache cluster support in OpenAccess?  Check out the docs (search for msmq).  In a nutshell, it's a queued service that evicts stale objects from other applications caches when someone updates an entity.  From the docs:

    "When deployment scenarios exist with more than one application using the L2cache for the same database (like an application server farm), then the variouscaches for the same database must be synchronized. This is done in such a way,that every modifying transaction sends its eviction requests to all participantsin the L2 cache cluster. This communication is done in an asynchronous fashion:There is a time window, in which one L2 cache (process A) is already evicted butanother L2 cache (process B) is not yet evicted. The size of the time windowdepends on the cache cluster implementation chosen."

    Cheers,
    Robert
Back to Top
DevCraft banner