Windows Phone 7 Database Rapid Repository V2.0 Caching

Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.

Download Rapid Repository from Microsoft Codeplex

Blog Tutorials

All entities used at runtime are put into a cache by default.

If you are likely to be getting all of the entities out of the database each time the application runs you can eager load the cache for much improved performance.

The eager load runs on a separate thread so as not to affect the application page rendering.

You call eager load for each entity type at application start up or in the main page constructor.

Eager Load
  1. public MainPage()
  2. {
  3.     InitializeComponent();
  4.  
  5.     EntityCache.EagerLoad<Customer>();
  6. }

 

If you need to turn off caching, you can set NoCache for each entity type you wish to be excluded at start up.

No Cache
  1. public MainPage()
  2. {
  3.     InitializeComponent();
  4.  
  5.     EntityCache.NoCache<Customer>();
  6. }

 

Summary

If you are eager loading to perform queries against the entities within the database faster, consider using Views and Filters instead as this will be much quicker that loading and querying the full list of entities.

I hope you find this useful.

Sean McAlinden.

No Comments