I have static class that holds some info
public static class SampleDataCache
{
private static Dictionary<string,SampleData> cacheDict = new Dictionary<string,object>()
public static Get(string key)
{
if(!cacheDict.Contains[key])
cacheDict.Add(key,new SampleData());
return cacheDict[key];
}
}
And when I refresh page I want SampleDataCache to keep its data.
Can I achieve this in simple way?
Since the cache, in its current form, is stored in memory then the data is naturally cast into oblivion when the page refreshes - that's a new instance of the application starting there. You might, however, be interested in utilising isolated storage in order to persist data per-user.
With isolated storage you essentially have a contained file system into which you can store data and then further retrieve it. One step in the right direction could be to make a class you want to represent a 'piece' of cached data, make it serializable, then using your static class as the cache controller you can read and write these objects from and to isolated storage.
Quickstart: Isolated Storage in Silverlight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With