This project is read-only.

IsolatedStorageCacheProvider usage

Feb 18, 2011 at 10:34 AM

Hey guys,

I looked at the streetcrime demo app and was trying to add the IsolatedStorageCacheProvider to my own project...
Small question, do you need to do anything to 'save' entries into the Isolated storage? Because each time I perform the .Add, the Key and Value count in the Isolated storage stays 0.
Is there maybe a smaller demo just for the usage of this provider? If needed I can send my demo solution...

Feb 18, 2011 at 10:02 PM


Thanks for the first question :)

The cache provider periodically persists to file automatically, currently fixed to every 15 seconds, so no you don't have to initiate a 'save' operation. I'll write a quick demo for you to show how it works.



Feb 18, 2011 at 11:59 PM

I've created a demo project in the Spikes directory - obviously creating this demo I found some bugs in the code :) So I've fixed these, checked in and rebuilt the beta release.

So I recommend download the source code, going to the Spikes directory and running the 'CacheProviderDemo'

The demo shows how to add both value types and reference types to the isolated cache provider - you can see what is happening to the cache provider by observing the debug statements in the output window of VS.Net.

I set the cache timeout to be 20 seconds, so you'll observe the following timeline:

Add value to cache provider,

15 second later the cache will be persisted to file automatically,

5 seconds after that the value will be purged from the cache,

10 seconds later the cache will be perisisted to file again...


A requirement for the cache provider is that all reference types support serialization by the SilverlightSerializer -

So you will see for the reference type class, ExampleReferenceTypeKey, I have implemented the required attribute and interface. Also because we are adding values to the cache as key-value pairs I have also implemented\overridden GetHashCode method to give a valid hash code for the class, and because I did that I've also overridden Equals and implemented the required methods.



Let me know if there are any issues...



Feb 20, 2011 at 7:01 PM

Woow Ollie,

Thanks for the fast reply :)

I'll have a look at your demo app... thanks!