This is a migrated thread and some comments may be shown as answers.

Refreshing the cache

4 Answers 237 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christian
Top achievements
Rank 1
Christian asked on 08 Apr 2009, 06:55 AM
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  

4 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 14 Apr 2009, 09:29 AM
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.
0
Christian
Top achievements
Rank 1
answered on 17 Apr 2009, 03:17 PM
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
0
Jan Blessenohl
Telerik team
answered on 20 Apr 2009, 04:31 PM
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.
0
Robert
Top achievements
Rank 2
answered on 21 Apr 2009, 02:31 PM
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
Tags
Development (API, general questions)
Asked by
Christian
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Christian
Top achievements
Rank 1
Jan Blessenohl
Telerik team
Robert
Top achievements
Rank 2
Share this question
or